How to create a script that list itself ?

Szabolcs Nagy nszabolcs at
Mon Jan 9 20:07:31 CET 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()


More information about the Python-list mailing list