Newbie question about Class

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Feb 13 11:54:23 EST 2007


En Tue, 13 Feb 2007 13:01:59 -0300, <JStoneGT at aol.com> escribió:

> But I'm still confused that what's the "real dictionary"?I can't know   
> this
> point.Please help and thanks  again.

I'm talking about a Python dictionary (a "real" one, as opposed to  
UserDict, which is a "fake" dictionary; it looks and acts like a  
dictionary but it's not).

py> from UserDict import UserDict
py> d = {"a": 1, "b": 2, "c": 3} # This is a "real" dictionary
# I create an UserDict instance, its initial contents come from a  
dictionary
py> ud1 = UserDict(d)	
py> ud1
{'b': 2, 'a': 1, 'c': 3}
# Now I create a second UserDict instance, its initial contents come from  
the UserDict instance
py> ud2 = UserDict(ud1)
py> ud2
{'b': 2, 'a': 1, 'c': 3}

-- 
Gabriel Genellina




More information about the Python-list mailing list