function attributes are like function objects

Barry A. Warsaw barry at
Fri Feb 2 22:32:37 EST 2001

>>>>> "GG" == Geoffrey Gerrietts <geoff at> writes:

    GG> Yeah, well, right, so you don't know it by its birth name, but
    GG> you still know it by the name you gave it, just like you call
    GG> me GG.

In other words, you're accessing the object though the variable it's
locally bound to (nothing special there).

    GG> Not to pick nits, just that the question is about
    GG> introspection, not about whether regular namespace semantics
    GG> work, or whether our functions are really first-class objects.

Okay, so introspection works no differently for functions as any other
object with writable attributes (e.g. classes, instances, modules).
You can use getattr() to test whether a function has a particular
attribute, and setattr() to set that attribute.

But maybe I'm missing the point of the question?  It's been a long
couple of days.

More information about the Python-list mailing list