Sailor5
November 24th, 2010, 09:41 PM
Ahoy Sailor!
So I've compiled my Python script using Py2Exe. Now I'm facing a dilemma, getting the file name of itself ( the file I compiled ).
I've used two different commands to get the name. However they both have issues.
print sys.argv[0]This works fine and dandy. If you execute the script via console. If you execute it via double clicking. It won't hold the name.
nme = inspect.currentframe().f_code.co_filenameThis comes back with the original source file name. So after we've built an executable from SOURCE.py to get EXECUTABLE.exe and use this method. It will come back with SOURCE.py not the executable name which we want.
What other methods are there?
Thanks Bye!
So I've compiled my Python script using Py2Exe. Now I'm facing a dilemma, getting the file name of itself ( the file I compiled ).
I've used two different commands to get the name. However they both have issues.
print sys.argv[0]This works fine and dandy. If you execute the script via console. If you execute it via double clicking. It won't hold the name.
nme = inspect.currentframe().f_code.co_filenameThis comes back with the original source file name. So after we've built an executable from SOURCE.py to get EXECUTABLE.exe and use this method. It will come back with SOURCE.py not the executable name which we want.
What other methods are there?
Thanks Bye!