Newbie question about Class

JStoneGT at aol.com JStoneGT at aol.com
Tue Feb 13 11:01:59 EST 2007


 


[quote]The idea behind that class is to act "as-if" it were a real  
dictionary.  
Dicts have an update method, and UserDict should too. But  it's not listed  
in the book (should appear a few lines below that  code); this is a  
possible implementation:

def update(self,  other):
for key in other.keys():
self.data[key] = other[key]

Given this method, __init__  works fine.
Using self.data.update(dict) is OK if the dict argument is a  real  
dictionary, but not if it's another UserDict.[/quote]
 
 
Thank you.
But I'm still confused that what's the "real dictionary"?I can't know  this 
point.Please help and thanks  again.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070213/7928ee4e/attachment.html>


More information about the Python-list mailing list