[Python-3000] Spooky behavior of dict.items() and friends

Benjamin Peterson musiccomposition at gmail.com
Thu Apr 3 00:37:13 CEST 2008


On Wed, Apr 2, 2008 at 5:33 PM, Jason Orendorff <jason.orendorff at gmail.com>
wrote:

> On Wed, Apr 2, 2008 at 5:08 PM, Mike Klaas <mike.klaas at gmail.com> wrote:
> >  ...and the majority of these cases would work fine with views (input
> >  to sorted(), etc).
>
> Suppose "the majority" here means 36 of the 46 cases.  Then what
> you're saying is, if I write .items() without thinking, there's about
> a 3% chance it won't work (10 out of 339 cases).  Forgive me:  the
> fact that you've gotten it down to 3%, e.g. by making items() return a
> view instead of an iterator, doesn't make me terrifically happy.

It's so easy to do what you want in those cases, though. Just by the view in
list.

>
>
> I'm OK with the status quo.  Maybe iteritems() is a wart, but I think
> views will be a much worse wart!
>
> If the only hard requirement is that dict lose *something* in Python
> 3.0, I suggest droping values() and itervalues(), as I never use them.
>  ;-)
>
> -j
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/musiccomposition%40gmail.com
>



-- 
Cheers,
Benjamin Peterson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20080402/f7649406/attachment.htm 


More information about the Python-3000 mailing list