Re: Newbie question about Class

2007-02-13 Thread JStoneGT
Thanks a lot.I've got it. En Tue, 13 Feb 2007 13:01:59 -0300, <[EMAIL PROTECTED]> 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 UserDic

Re: Newbie question about Class

2007-02-13 Thread Gabriel Genellina
En Tue, 13 Feb 2007 13:01:59 -0300, <[EMAIL PROTECTED]> 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; i

Re: Newbie question about Class

2007-02-13 Thread JStoneGT
[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 ot

Re: Newbie question about Class

2007-02-13 Thread Gabriel Genellina
En Tue, 13 Feb 2007 03:56:21 -0300, <[EMAIL PROTECTED]> escribió: > I'm reading the book of "Dive into Python" and got these code pieces: > class UserDict: > def __init__(self, dict=None): self.data = {} > if dict is not None: self.update(dict) > My question is,for the statement of:

Newbie question about Class

2007-02-12 Thread JStoneGT
I'm reading the book of "Dive into Python" and got these code pieces: class UserDict: def __init__(self, dict=None): self.data = {} if dict is not None: self.update(dict) My question is,for the statement of: if dict is not None: self.update(dic

Re: Newbie question about class operator overloading

2005-02-16 Thread Steven Bethard
Rory Campbell-Lange wrote: Hi Steve I've been playing around with your two suggestions. The Record class is an elegant solution. It doesn't however help in the case where the class has the following general data structure (something I should have stated originally): class.config1 = param

Re: Newbie question about class operator overloading

2005-02-16 Thread Rory Campbell-Lange
Hi Steve I've been playing around with your two suggestions. The Record class is an elegant solution. It doesn't however help in the case where the class has the following general data structure (something I should have stated originally): class.config1 = param class.config2 = param

Re: Newbie question about class operator overloading

2005-02-15 Thread Steven Bethard
Rory Campbell-Lange wrote: Hi. I'm just starting to use python. I am anxious about how best to set and access items one level down in a data structure if I am using __setitem__ and __getitem__. At the moment I can do for a data structure Data: object.Data = { 'one' : [1, 2, {}, 4],

Re: Newbie question about class operator overloading

2005-02-15 Thread Rory Campbell-Lange
Anyone out there? Criticism about the objective of my question, not just the execution, gratefully received! Basically, if I have a class This: def __init__(self, x, y): self.x=x self.y=y self.data = {} and then make all my setitem and getitem cal

Newbie question about class operator overloading

2005-02-15 Thread Rory Campbell-Lange
Hi. I'm just starting to use python. I am anxious about how best to set and access items one level down in a data structure if I am using __setitem__ and __getitem__. At the moment I can do for a data structure Data: object.Data = { 'one' : [1, 2, {}, 4], 'two' : [5, 6,