How to create a script that list itself ?

Szabolcs Nagy nszabolcs at gmail.com
Mon Jan 9 14:07:31 EST 2006


> But is there a way / a variable that contains the current file in
> memory ?
yes: import __main__

you can do:

import inspect
import __main__
print inspect.getsource(__main__)

or simply:

print open(__file__).read()


nsz




More information about the Python-list mailing list