[issue20606] Operator Documentation Example doesn't work
Gareth Rees added the comment: This is a duplicate of #22180, which was fixed in changeset 9c250f34bfa3 by Raymond Hettinger in branch '3.4'. The fix just removes the bad example, as in my patch. So I suggest that this issue be closed as a duplicate. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
Andrew Svetlov added the comment: Closed -- nosy: +asvetlov resolution: - duplicate stage: - resolved superseder: - operator.setitem example no longer works in Python 3 due to lazy map ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
Changes by Benjamin Peterson benja...@python.org: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
New submission from silentbat: In the Docs for Python3.3 http://docs.python.org/3.3/library/operator.html#operator.__setitem__ the following example doesn't work. -- assignee: docs@python components: Documentation messages: 211079 nosy: docs@python, silent.bat priority: normal severity: normal status: open title: Operator Documentation Example doesn't work type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
Gareth Rees added the comment: The failing example is: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) which works in Python 2 where map returns a list, but not in Python 3 where map returns an iterator. Doc/library/operator.rst follows the example with this note: .. XXX: find a better, readable, example Additional problems with the example: 1. It's poorly motivated because a dictionary comprehension would be simpler and shorter: d = {i: chr(i) for i in range(256)} 2. It's also unclear why you'd need this dictionary when you could just call the function chr (but I suppose some interface might require a dictionary rather than a function). 3. To force the map to be evaluated, you need to write list(map(...)) which allocates an unnecessary list object and then throws it away. To avoid the unnecessary allocation you could use the consume recipe from the itertools documentation and write collections.deque(map(...), maxlen=0) but this is surely too obscure to use as an example. I had a look through the Python sources, and made an Ohloh Code search for operator.setitem and I didn't find any good examples of its use, so I think the best thing to do is just to delete the example. http://code.ohloh.net/search?s=%22operator.setitem%22pp=0fl=Pythonmp=1ml=1me=1md=1ff=1filterChecked=true -- nosy: +Gareth.Rees ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20606] Operator Documentation Example doesn't work
Changes by Gareth Rees g...@garethrees.org: -- keywords: +patch Added file: http://bugs.python.org/file34059/operator.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20606 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com