Function to retrieve running script

H

Harlin Seritt

Is there a function that allows one to get the name of the same script
running returned as a string?

Thanks,

Harlin Seritt
 
A

Alex Martelli

Harlin Seritt said:
Is there a function that allows one to get the name of the same script
running returned as a string?

Something like:

import sys
def f():
return sys.modules['__main__'].__file__

might help.


Alex
 
M

Mike Meyer

Harlin Seritt said:
Is there a function that allows one to get the name of the same script
running returned as a string?

The questions a little ambiguous, but one answer might be:

import sys
myname = sys.argv[0]

<mike
 
H

Harlin Seritt

Thanks Mike,

that will work just as well... just disappointed in myself that i lack
the creativity to think of something that simple ;-)

thanks,

Harlin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,229
Messages
2,571,160
Members
47,785
Latest member
deepusaini

Latest Threads

Top