<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Guido van Rossum wrote:<br>
<blockquote
cite="mid:ca471dc20709151901x4524dd94j252f80808b911611@mail.gmail.com"
type="cite">
<pre wrap="">On 9/15/07, Greg Ewing <a class="moz-txt-link-rfc2396E" href="mailto:greg.ewing@canterbury.ac.nz"><greg.ewing@canterbury.ac.nz></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.</pre>
</blockquote>
<pre wrap="">This sounds awfully close to bikeshedding. Change too many details
like this and you cause death by a 1000 pinpricks for existing apps.
sys.argv[0] *does* get used (though arguably rarely in the same way as
sys.argv[1:]).</pre>
</blockquote>
<br>
+0.5 on Greg Ewing's proposal.<br>
<br>
argv[0] has little in common with argv[1:]; why should the user have to
differentiate them? I see this as yet one more messy detail of the OS
that Python could hide for me. Looking at it with fresh eyes,
I think<br>
for a in sys.arguments:<br>
is a lot prettier than<br>
for a in sys.argv[1:]:<br>
After all: what's that 1: doing there? Why the magic number? Why does
argv have the script name in [0], anyway? None of my other
functions/members
are forced to take themselves as their first argument.<br>
<br>
Taking it to its logical conclusion, I further propose:<br>
sys.raw_argv -- the original bytes as they came in from from the OS<br>
sys.argv -- raw_argv converted into (unicode) strings, not expected
to be used by users<br>
sys.arguments -- sys.argv[1:]<br>
sys.script_path -- sys.argv[0]<br>
sys.split_argv -- callable that takes an argv-style array (strings,
not bytes) and assigns it into argv, arguments, and script_path,
slicing as appropriate<br>
<br>
Yes, the format of argv has thirty years of history; yes I don't really
expect this discussion to get anywhere. But I hate having arbitrary
idioms in Python, and I wanted to cast my vote into the swirling void
before this idea totally died.<br>
<br>
If nothing else, at least we could fix the proviso for argv[0]: "(it is
operating system dependent whether this is a full pathname or not)."
How about we always ensure it is an absolute path?<br>
<br>
<br>
My "there's only one way to do it" reflex is fighting it out with my
"beautiful is better than ugly" reflex,<br>
<br>
<br>
<i>larry</i>
</body>
</html>