Counterintuitive Python behavior

dominikush at yahoo.com dominikush at yahoo.com
Wed Apr 17 10:31:46 EDT 2002


> > I understand that! But my main objection remains: Why should
> > I care about the type of object being handled by a dictionary?
> 
> You shouldn't: whatever types of objects are the dictionary's values,
> method .values() will ALWAYS return a new list object whose items
> refer to EXACTLY the same objects as the dictionary's values.

I got it after I read your and Michaels posts!
 
> > This could not only break unit tests but also make maintenance
> > of ``old'' code somewhat painful.
> 
> I don't understand what you're talking about.  My sentence above
> was true at least since Python 1.5.2 (probably earlier, but that's
> when I hopped aboard).
> 
> Alex

Now, I don't understand it myself anymore ;-)

Dominikus



More information about the Python-list mailing list