Dive into Python 5.5

Daniel Nogradi nogradi at gmail.com
Wed Jun 13 06:03:39 EDT 2007


> class UserDict:
>     def __init__(self, dict=None):
>         self.data = {}
>         if dict is not None: self.update(dict)
>
> I just don't understant this code, as it is not also mention in the
> book. the update is a method of a dict right? in my understanding the
> last statement should be self.data.update(dict).
>
> someone please explain to me what happen where?

You are right, this code will not work, and your suggestion is a reasonable one.

HTH,
Daniel



More information about the Python-list mailing list