Python 3: dict & dict.keys()

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jul 25 01:57:37 EDT 2013


On Wed, 24 Jul 2013 17:59:43 -0700, Ethan Furman wrote:

>> Repeat after me: "In Python 2, d.keys() returns a list of keys, so if I
>> want a list of keys in Python 3, call list explicitly list(d.keys())."
> 
> Actually, I would recommend `list(d)`, which also works the same in both
> 2 and 3.

Fair point.



-- 
Steven



More information about the Python-list mailing list