Guido van Rossum wrote:
On 9/15/07, Greg Ewing <[EMAIL PROTECTED]> wrote:
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.
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:]).

+0.5 on Greg Ewing's proposal.

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
   for a in sys.arguments:
is a lot prettier than
   for a in sys.argv[1:]:
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.

Taking it to its logical conclusion, I further propose:
   sys.raw_argv -- the original bytes as they came in from from the OS
sys.argv -- raw_argv converted into (unicode) strings, not expected to be used by users
   sys.arguments -- sys.argv[1:]
   sys.script_path -- sys.argv[0]
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

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.

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?


My "there's only one way to do it" reflex is fighting it out with my "beautiful is better than ugly" reflex,


/larry/
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to