Re: [Tutor] modified dictionary class

2010-12-06 Thread Hugo Arts
On Mon, Dec 6, 2010 at 4:32 PM, John wrote: > Hugo, > > Thank you for the response, it's very helpful. I posted a question > earlier to this list (or possibly numpy) about how to create a 'matlab > like structure'. This was early in my learning of Python, and yes, the > intention was to have somet

Re: [Tutor] modified dictionary class

2010-12-06 Thread John
Hugo, Thank you for the response, it's very helpful. I posted a question earlier to this list (or possibly numpy) about how to create a 'matlab like structure'. This was early in my learning of Python, and yes, the intention was to have something that was similar to a matlab structure... now, I've

Re: [Tutor] modified dictionary class

2010-12-06 Thread Hugo Arts
On Mon, Dec 6, 2010 at 2:47 PM, Alan Gauld wrote: > Oops, too quick. I neant to add: > > But this line seems to return a value so the return values of this function > seem to be incompatible which is not a good design pattern. I agree it's not the clearest way to do this, but not because of incom

Re: [Tutor] modified dictionary class

2010-12-06 Thread Alan Gauld
"Joel Goldstick" wrote def __getattr__(self, attr): # Fake a __getstate__ method that resturns None if attr == "__getstate__": return lambda: None why not "return None"? return self[attr] Oops, too quick. I neant to add: But this line seems to retur

Re: [Tutor] modified dictionary class

2010-12-06 Thread Alan Gauld
"Joel Goldstick" wrote def __getattr__(self, attr): # Fake a __getstate__ method that resturns None if attr == "__getstate__": return lambda: None why not "return None"? Presumably the caller is expecting a function that he can call. The lambda is such a functio

Re: [Tutor] modified dictionary class

2010-12-06 Thread Joel Goldstick
On Mon, Dec 6, 2010 at 7:34 AM, John wrote: > Hello all, > > I have been using this class extensively in my modules / scripts. It > provides the ability to .reference dictionary values. I find it handy, > but am afraid it may come back to haunt me at some point. Is there > anything wrong with usi

[Tutor] modified dictionary class

2010-12-06 Thread John
Hello all, I have been using this class extensively in my modules / scripts. It provides the ability to .reference dictionary values. I find it handy, but am afraid it may come back to haunt me at some point. Is there anything wrong with using this? class Structure(dict): """ A 'fancy' dicti