Message103166
The examples of set operations in http://docs.python.org/dev/library/stdtypes#dictionary-view-objects don't work in the current 2.7 trunk:
-> ./python.exe
Python 2.7b1+ (trunk:80084:80085M, Apr 14 2010, 21:17:06)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
>>> keys = dishes.viewkeys()
>>> keys & {'eggs', 'bacon', 'salad'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'dict_keys' and 'set'
>>> keys | {'eggs'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'dict_keys' and 'set'
Is this a documentation bug, and set operations are only supported in 3.x? Or does the code need to be fixed?
(Assigned to Alexandre, since he committed the backport patch; please feel free to reassign. Marking as release blocker; if it's a documentation bug, we can lower the priority.) |
|
| Date |
User |
Action |
Args |
| 2010-04-15 01:23:48 | akuchling | set | recipients:
+ akuchling, alexandre.vassalotti |
| 2010-04-15 01:23:48 | akuchling | set | messageid: <1271294628.24.0.991589115807.issue8404@psf.upfronthosting.co.za> |
| 2010-04-15 01:23:46 | akuchling | link | issue8404 messages |
| 2010-04-15 01:23:44 | akuchling | create | |
|