sys module - argv, but no argc ??

Gabe Newcomb Gabe.Newcomb at noetix.com
Fri Aug 2 17:25:54 CEST 2002


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

	len(sys.argv)

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

Alternately, just do

	len(sys.argv) - 1

Gabe

-----Original Message-----
From: James J. Besemer [mailto:jb at cascade-sys.com]
Sent: Friday, August 02, 2002 12:01 AM
To: Tony C
Cc: python-list at python.org
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 )

--jb


--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com



-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list