{"action":"created","issue":{"url":"https://api.github.com/repos/pytoolz/toolz/issues/279","labels_url":"https://api.github.com/repos/pytoolz/toolz/issues/279/labels{/name}","comments_url":"https://api.github.com/repos/pytoolz/toolz/issues/279/comments","events_url":"https://api.github.com/repos/pytoolz/toolz/issues/279/events","html_url":"https://github.com/pytoolz/toolz/issues/279","id":110726554,"number":279,"title":"pluck won't accept tuple of indexes","user":{"login":"Jason-Green-Aver","id":11428909,"avatar_url":"https://avatars.githubusercontent.com/u/11428909?v=3","gravatar_id":"","url":"https://api.github.com/users/Jason-Green-Aver","html_url":"https://github.com/Jason-Green-Aver","followers_url":"https://api.github.com/users/Jason-Green-Aver/followers","following_url":"https://api.github.com/users/Jason-Green-Aver/following{/other_user}","gists_url":"https://api.github.com/users/Jason-Green-Aver/gists{/gist_id}","starred_url":"https://api.github.com/users/Jason-Green-Aver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jason-Green-Aver/subscriptions","organizations_url":"https://api.github.com/users/Jason-Green-Aver/orgs","repos_url":"https://api.github.com/users/Jason-Green-Aver/repos","events_url":"https://api.github.com/users/Jason-Green-Aver/events{/privacy}","received_events_url":"https://api.github.com/users/Jason-Green-Aver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-09T19:58:58Z","updated_at":"2015-10-09T21:15:27Z","closed_at":null,"body":"Although the docs say \"``ind`` can be either a single string/index or a sequence of strings/indices.\",\r\nI've had no luck with tuples:\r\n\r\nPython 3.4.2 (default, Nov 30 2014, 16:46:39) \r\nIn [1]: import toolz\r\nIn [2]: dicts = [{'k1': 'v1'},{'k1': 'v2'}]\r\nIn [3]: keys = ('k1',)\r\nIn [4]: list(toolz.pluck(keys, dicts))\r\n\r\nKeyError                                  Traceback (most recent call last)\r\n<ipython-input-4-71ca2c465d1a> in <module>()\r\n----> 1 list(toolz.pluck(keys, dicts))\r\n\r\nKeyError: ('k1',)\r\n\r\nIn [5]: list(toolz.pluck(list(keys), dicts))                                                                                                                                                                                                                                               \r\nOut[5]: [('v1',), ('v2',)]"},"comment":{"url":"https://api.github.com/repos/pytoolz/toolz/issues/comments/146987727","html_url":"https://github.com/pytoolz/toolz/issues/279#issuecomment-146987727","issue_url":"https://api.github.com/repos/pytoolz/toolz/issues/279","id":146987727,"user":{"login":"Digenis","id":2230180,"avatar_url":"https://avatars.githubusercontent.com/u/2230180?v=3","gravatar_id":"","url":"https://api.github.com/users/Digenis","html_url":"https://github.com/Digenis","followers_url":"https://api.github.com/users/Digenis/followers","following_url":"https://api.github.com/users/Digenis/following{/other_user}","gists_url":"https://api.github.com/users/Digenis/gists{/gist_id}","starred_url":"https://api.github.com/users/Digenis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Digenis/subscriptions","organizations_url":"https://api.github.com/users/Digenis/orgs","repos_url":"https://api.github.com/users/Digenis/repos","events_url":"https://api.github.com/users/Digenis/events{/privacy}","received_events_url":"https://api.github.com/users/Digenis/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T21:15:27Z","updated_at":"2015-10-09T21:15:27Z","body":"Indeed, https://github.com/pytoolz/toolz/blob/53146dc42359fa1a3e479856f0c400d2ed4e883f/toolz/itertoolz.py#L726\r\n\r\nProbably, either the documentation or code will be fixed.\r\n\r\nFrom my perspective, they are both wrong.\r\nI'd expect `ind` to  be passed directly to the `__getitem__` method\r\nof each element of the sequence.\r\n\r\nI think no simple solution works because:\r\n\r\nSay, the code gets fixed to check for tuple instances,\r\npluck won't work for dictionaries whose keys are tuples.\r\n\r\nSay, the documentation gets fixed to state that only lists behave like this,\r\npluck won't work for dictionary subclasses that define a custom `__hash__` method\r\nthat enable them to work with lists.\r\n\r\nYou can substitute words above,\r\nlike `dictionary` with `MutableMapping`\r\nand `list` with `MutableSequence`\r\njust to make the problem look wider.\r\n\r\nI think it could be much simpler if `ind` was restricted to a single type.\r\nSo rather change the doc to: *`ind` must be a sequence of indices*\r\nand remove 2 lines to implement it as such.\r\nNow, if someone wants to pluck a single index/key\r\nit costs nothing to pass it wrapped in `[]`.\r\nE.g. `pluck(key, seqs)` will need to become `pluck([key], seqs)`\r\n\r\nBut you can disregard all the above.\r\nIt haven't occurred to me to actually use `pluck`\r\nbut I thought my comment can be somehow constructive."}}