[EMAIL PROTECTED] (Roy Smith) writes: > Objects can have attributes (data) and operations associated with > them. It would be very convenient to use the "." syntax to access > both of these, i.e. be able to say: > > print handle.someAttribute > print handle.someOperation (arg1, arg2) > > I'm using __getattr__() to process both of these constructs, and > herein lies the rub; I need to do different things depending on > whether the name is an attribute or an operation. I can ask the DB > for a list of the names of all the operations supported by a given > object, but that's a fairly expensive thing to do, so I'd rather avoid > it if possible. It would be really nice if I had some way to find > out, from inside __getattr__(), if the value I'm about to return will > get called as a function (i.e., the name is followed by an open > paren). I can't see any way to do that, but maybe I'm missing > something? > > Any ideas?
Fnorb (a pure-Python CORBA orb) dealt with this by not allowing attributes per se. Instead, it provided _get_AttributeName and _set_AttributeName as appropriate for each attribute in the IDL. Doing this means that *everything* you hand back from __getattr__ is going to be a callable, and presumably called at some point. Properties postdate Fnorb, so weren't considered in it's design. You might be able to do something with them as well. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list