[Python-ideas] sys.args

Chris Angelico rosuav at gmail.com
Sat Jul 27 00:08:55 CEST 2013


On Fri, Jul 26, 2013 at 5:40 PM, Ryan <rymg19 at gmail.com> wrote:
> But that violates the Python Zen: 'There should be one, and preferably only
> one, way to do it'. The name argv isn't meaningless. I believe it comes from
> C. argv was the argument vector, i.e. the container for the arguments.
>

The name comes from the C pair of argc/argv, where you need a separate
integer count of args. So it's not wholly appropriate to Python.
Ironically, it's not even mandated by C (it's just a convention,
equivalent to Python methods having a first argument named 'self'),
but it's a fixed name in Python, where it's inaccurate. But it's
something that's found in many other languages too, so it's something
plenty of people will understand (particularly as 'argv' (almost)
invariably refers to the program's arguments, while other uses of
'arg' might mean some particular function's args), so the name isn't
terrible; and the backward compatibility loss (or the clarity loss of
keeping both) is the strongest ... uhh, argument.

ChrisA


More information about the Python-ideas mailing list