Re: Dive into Python 5.5

2007-06-13 Thread 7stud
On Jun 13, 2:40 am, james_027 <[EMAIL PROTECTED]> wrote: > Hi, > > 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

Re: Dive into Python 5.5

2007-06-13 Thread Daniel Nogradi
> 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

Re: Dive into Python 5.5

2007-06-13 Thread Ben Finney
james_027 <[EMAIL PROTECTED]> writes: > class UserDict: > def __init__(self, dict=None): > self.data = {} > if dict is not None: self.update(dict) The code confusingly shadows the builtin 'dict' type with a poorly-chosen parameter name. See if this makes things less confusing:

Dive into Python 5.5

2007-06-13 Thread james_027
Hi, 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