[Python-3000] Move argv[0]? (Re: Unicode and OS strings) (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Sep 16 03:38:17 CEST 2007


Also "argv" sounds more low-level than something like "arguments".

While we're on the subject of argv, I've been wondering whether py3k might want to revisit the idea of having argv[0] be the program name. In my experience, one almost never wants to treat argv[0] the same way as the rest of the arguments.

Putting the program name into argv[0] is a neat trick in C that's relatively harmless, because it's just as easy to start iterating from 1 than 0, but in Python it makes all argument-processing code more complicated than necessary.

It also provides a nasty trap for the unwary, as I discovered one day when I wrote a program for deleting files that deleted itself the first time I ran it. :-)

Changing the existing behaviour of argv would probably be too disruptive, so how about relegating argv to a low-level detail and providing something else for everyday use that omits argv[0]?

sys.arguments would sound quite nice for that.

-- Greg



More information about the Python-3000 mailing list