[Python-Dev] Handling of sys.args (Re: User's complaints)
Nick Coghlan
ncoghlan at gmail.com
Fri Jul 14 11:31:11 CEST 2006
Greg Ewing wrote:
> Nick Maclaren wrote:
>> On systems that are not Unix-derived (which, nowadays, are rare),
>> there is commonly no such thing as a program name in the first place.
>> It is possible to get into that state on some Unices - i.e. ones which
>> have a form of exec that takes a file descriptor, inode number or
>> whatever.
>
> I don't think that applies to the Python args[] though,
> since its args[0] isn't the path of the OS-level
> executable, it's the path of the main Python script.
>
> But you could still end up without one, if the main
> script comes from somewhere other than a file.
sys.argv[0] can end up being None in Python 2.5 - zipimporter objects don't
currently expose the info runpy.run_module needs to set __file__ and
sys.argv[0] correctly, so they'll both end up being None if you use -m to run
a module from a zipfile.
PEP 302 went a fairly long way towards decoupling imports from the filesystem
lay out, but it isn't all the way there just yet.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list