How to pass a reference to the current module
Paul Rubin
http
Sat Aug 4 01:06:25 EDT 2007
Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> I'll point at the difficulty in using getattr for extracting a function
> from the current module:
> >>> func = getattr(???, 'f') # what should go there?
Hmm, it's a pain that there's no clean way to get at the current
module. PEP 3130 shows some icky and unreliable ways, e.g.
func = getattr(sys.modules[__name__], 'f')
PEP 3130's goal was to add a clean way to do this. Unfortunately it
was rejected.
More information about the Python-list
mailing list