sys module - argv, but no argc ??

Gabe Newcomb Gabe.Newcomb at
Fri Aug 2 11:25:54 EDT 2002

But beware that sys.argv includes the script as the first item
(sys.argv[0]), so if you do:


you will actually get the number of args passed + 1.

Alternately, just do

	len(sys.argv) - 1


-----Original Message-----
From: James J. Besemer [mailto:jb at]
Sent: Friday, August 02, 2002 12:01 AM
To: Tony C
Cc: python-list at
Subject: Re: sys module - argv, but no argc ??

Tony C wrote:

> I've imported the sys module, and I'm SHOCKED that there is no way to
> access the argument count.
> The docs talk about accessing argv, but nothing about the argument
> count.

No need.  Use:

    len( sys.argv )


James J. Besemer  503-280-0838 voice  503-280-0375 fax
mailto:jb at


More information about the Python-list mailing list