python -c cmd bug?

Fredrik Lundh fredrik at pythonware.com
Wed Mar 13 03:04:53 EST 2002


"erik_w" wrote:

> When I do
> >python -c "import sys;print sys.argv"
> ['-c']
>
> (Python 2.1.2 on NT4)
>
> Is this the right behaviour?  I would expect that the -c was an option
> to the python interpreter, not to my script.

    http://www.python.org/doc/current/lib/module-sys.html

    "argv"

    "The list of command line arguments passed to
    a Python script. argv[0] is the script name (it is
    operating system dependent whether this is a full
    pathname or not). If the command was executed
    using the -c command line option to the interpreter,
    argv[0] is set to the string '-c'. If no script name
    was passed to the Python interpreter, argv has
    zero length."

</F>





More information about the Python-list mailing list