[Python-Dev] Handling of sys.args (Re: User's complaints) (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jul 13 10:59:06 CEST 2006
- Previous message: [Python-Dev] User's complaints
- Next message: [Python-Dev] Handling of sys.args (Re: User's complaints)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ka-Ping Yee wrote:
Having to 'import sys' to get at the command-line arguments always seemed awkward to me. 'import sys' feels like it should be a privileged operation (access to interpreter internals), and getting the command-line args isn't privileged.
Would it help if sys were pre-imported into the builtins? Or do you think that args shouldn't live in sys at all?
Recently I've come to appreciate the ability to get at the args from anywhere, instead of having to catch them from a call to main() and pass them around. So I'd like to still be able to import them from somewhere if I want (doesn't have to be sys, though).
And while we're on the subject, anyone think it would be a good idea to drop the silly feature of having the program name as args[0]? You almost never want to treat it the same way as the rest of the args, so the first thing you always do is args[1:].
It's not so bad in C, where it's just as easy to start indexing argv from 1 instead of 0. But it makes no sense in Python, IMO. It would be much more sensible to move it into a separate attribute of whatever module we decide to put args in.
-- Greg
- Previous message: [Python-Dev] User's complaints
- Next message: [Python-Dev] Handling of sys.args (Re: User's complaints)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]