function attributes are like function objects

Geoffrey Gerrietts geoff at homegain.com
Sat Feb 3 09:39:21 CET 2001


Aahz writes:
> I think the issue is that Geoffrey suddenly realized that there's no
> "self" equivalent for functions.

Not so suddenly as maybe it seems. I wasn't aware of any mechanism that
would help me out there; I just wondered whether one might be part of the
package. It seemed like an obvious corollary to me; if the function is going
to be carrying around this bit of state, it should probably have access to
it, sorta in the way that globals() lets you at a module's __dict__.

Fredrik has answered my question, though: there's nothing on the drawing
board that will let me at the attributes without first having an outside
handle on the object, and nothing that will give me an outside handle on it
from the inside. Maybe nested scopes will help that? Maybe not.

If function attributes make it easier for some folks, that's great. I 
thought maybe I saw a niche they might fill for me, but now I'm back to
wait-and-see; I'll wait for a final release before I adopt, anyway. :)

Thanks,
--G.





More information about the Python-list mailing list