Bug in Python set

Aahz aahz at pythoncraft.com
Sun May 2 08:23:23 EDT 2010


In article <0bd314a8-db65-43f1-a999-521e2ed71cad at n15g2000yqf.googlegroups.com>,
dmitrey  <dmitrey.kroshko at scipy.org> wrote:
>
>Python 2.6.5 r265:79063
>>>>set().update(set()) is None
>True
>while I expect result of update to be set.
>Also, result of
>set().add(None)
>is None while I expect it to be set with element None (or, maybe, it
>should be empty set?)

Why are you assuming that your expectations are correct?  Generally
speaking, Python methods that mutate do *not* return the original object,
precisely to make sure you don't make stupid mistakes.

You should probably read this:

http://www.catb.org/~esr/faqs/smart-questions.html
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan



More information about the Python-list mailing list