predicting function calls?
OKB (not okblacke)
brenNOSPAMbarn at NObrenSPAMbarn.net
Wed Dec 28 10:45:13 EST 2005
Roy Smith wrote:
> 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).
What do you do if the person does:
x = handle.someOperation
x(arg1, arg2)
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
More information about the Python-list
mailing list