[Python-3000] Warning about future-unsafe usage patterns in Python 2.x e.g. dict.keys().sort() (original) (raw)
Ronald Oussoren ronaldoussoren at mac.com
Mon Aug 28 16:46:53 CEST 2006
- Previous message: [Python-3000] Warning about future-unsafe usage patterns in Python 2.x e.g. dict.keys().sort()
- Next message: [Python-3000] regex literals?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 28-aug-2006, at 16:21, Edward C. Jones wrote:
Brian Quinlan said: It is my understanding that, in Python 3000, certain functions and methods that currently return lists will return some sort of view type (e.g. dict.values()) or an iterator (e.g. zip). So certain usage patterns will no longer be supported e.g. d.keys().sort(). I use this idiom fairly often: d = dict() ... thekeys = d.keys() thekeys.sort() for key in thekeys: ... What should I use in Python 3.0?
for key in sorted(d.keys()): ...
This works in python 2.4 as well.
Ronald
- Previous message: [Python-3000] Warning about future-unsafe usage patterns in Python 2.x e.g. dict.keys().sort()
- Next message: [Python-3000] regex literals?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]