Should: "for k,v in **dictionary_instance" work?

Dustan DustanGroups at gmail.com
Sat Jun 16 01:01:30 CEST 2007


On Jun 15, 2:17 pm, keithgabryel... at gmail.com wrote:
> Does it make sense to provide this syntax for iterating key/value
> pairs from a dictionary?
>
> for k,v in **dict():
>    print k,v
>
> why is this not the same as:
>
> for k,v in dict().items():
>   print k,v
>
> for that matter, why the heck doesn't a dictionary default to
> returning a tuple
> k,v pair from its iterator?
>
> Pax, Keith
>
> Ps, I'm sure someone has thought of these things before, probably been
> answered before, but I'm sure I didn't find reference to them when i
> searched.

The answer is simply for history and for clarity.




More information about the Python-list mailing list