setting program name, like $0= in perl?
Emile van Sebille
emile at fenx.com
Tue Jun 9 17:16:49 EDT 2009
On 6/9/2009 1:06 PM mh at pixar.com said...
> I'm sure this is a FAQ, but I certainly haven't been able
> to find an answer.
>
> Is it possible to set the program name as seen by the
> operating system or lower-level libraries?
>
> I'm connecting to a database, and the runtime helpfully
> sends some information to the server, such as username,
> pid, and program name.
>
> Unfortunately, all my python programs get the name
> '/usr/bin/python', and I would like to force that to
> be the names of the individual scripts.
If you include the shebang as first line and execute the script directly
I think it'll work.
---- test.py----
#!/usr/bin/python
import sys
print sys.argv[0]
----------------
Emile
>
> Many TIA!
> Mark
>
More information about the Python-list
mailing list