sys module - argv, but no argc ??
Greg Ewing
see_reply_address at something.invalid
Mon Aug 5 01:25:39 EDT 2002
Terry Reedy wrote:
> "Gabe Newcomb" <Gabe.Newcomb at noetix.com> wrote in message
>>so if you do: len(sys.argv) you will actually get the number of args
>>
> passed + 1.
>
> Which is also true of argc in C. Python is here mimicking C, which is
> what the O.P. wanted.
I can imagine some people being surprised that Python,
which generally takes a higher-level view of things,
*does* mimic C so closely on this point.
I remember the time I wrote a Python program which
essentially did
import sys, os
for f in sys.argv:
os.unlink(f)
and was amused to find that, the first time it
was run, it worked perfectly and then deleted
itself. :-)
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list