How to get current module object
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Feb 18 02:55:53 EST 2008
More information about the Python-list mailing list
Mon Feb 18 02:55:53 EST 2008
- Previous message (by thread): How to get current module object
- Next message (by thread): How to get current module object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
En Sun, 17 Feb 2008 16:25:44 -0200, Alex <noname9968 at gmail.com> escribi�: > Can I get reference to module object of current module (from which the > code is currently executed)? I know __import__('filename') should > probably do that, but the call contains redundant information (filename, > which needs to be updated), and it'll perform unnecessary search in > loaded modules list. > > It shouldn't be a real problem (filename can probably be extracted from > the traceback anyway), but I wonder if there is more direct and less > verbose way. sys.modules[__name__] Why do you want to get the module object? globals() returns the module namespace, its __dict__, perhaps its only useful attribute... -- Gabriel Genellina
- Previous message (by thread): How to get current module object
- Next message (by thread): How to get current module object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list