getattr() woes

2004-12-28 Thread Thomas Rast
Hello I've found out about a fundamental problem of attribute lookup, the hard way. asyncore.py uses the following code: class dispatcher: # ... def __getattr__(self, attr): return getattr(self.socket, attr) Now suppose that I'm asking for some attribute not provided by dispatch

Re: getattr() woes

2004-12-28 Thread Aahz
In article <[EMAIL PROTECTED]>, Thomas Rast <[EMAIL PROTECTED]> wrote: > >I've found out about a fundamental problem of attribute lookup, the >hard way. Maybe. >asyncore.py uses the following code: > >class dispatcher: ># ... >def __getattr__(self, attr): >return getattr(self.soc

Re: getattr() woes

2004-12-28 Thread David M. Cooke
[EMAIL PROTECTED] (Aahz) writes: > In article <[EMAIL PROTECTED]>, > Thomas Rast <[EMAIL PROTECTED]> wrote: >> >>class dispatcher: >># ... >>def __getattr__(self, attr): >>return getattr(self.socket, attr) >> > import asyncore > class Peer(asyncore.dispatcher): >>... d

Re: getattr() woes

2004-12-29 Thread Nicolas Fleury
David M. Cooke wrote: Ideally, I think the better way is if getattr, when raising AttributeError, somehow reused the old traceback (which would point out the original problem). I don't know how to do that, though. Maybe a solution could be to put the attribute name in the AttributeError exception

Re: getattr() woes

2004-12-30 Thread Kamilche
Thomas Rast wrote: I've found out about a fundamental problem of attribute lookup, the hard way... Is there anything that can be done about this? It seems to me that the main problem is you're raising an AttributeError when an attribute is private. AttributeError is only raised when an attribute