how to make a code object a function

Emile van Sebille emile at fenx.com
Sun Jan 4 11:26:30 EST 2004


Diez B. Roggisch:
> Just out of curiosity - is there a way to know the name of a code
object you
> know nothing about except that it will become a function definition?
I
> guess I could go for some AST-stuff looking for a "def foo"
statement, so I
> know I will end up having defined foo when exec'ing the code object.
>

I'm not quit sure what you're asking, but does sets help?

>>> ns = locals().keys()
>>> testing = 1
>>> print sets.Set(locals().keys()) - sets.Set(ns)
Set(['testing'])


Emile van Sebille
emile at fenx.com




More information about the Python-list mailing list