sys module - argv, but no argc ??

François Pinard pinard at iro.umontreal.ca
Sat Aug 3 01:24:58 CEST 2002


[Tony C]

> I've imported the sys module, and I'm SHOCKED that there is no way to
> access the argument count.

Indeed, it would be shocking if there was no way.  Have more confidence
in Python design, and you will soon be happier! :-)

> The docs talk about accessing argv, but nothing about the argument count.
> Was something omitted from the docs ?

The way to get the length of a list is surely documented along with lists,
but not repeated for each and every list Python offers, that would soon
become tedious.

> How do Python users get around this ?

Merely by using len(sys.argv).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list