[Python-bugs-list] stdin and arguments (PR#78)

Tim Peters tim_one@email.msn.com
Sun, 12 Sep 1999 17:27:40 -0400


[frido@nl.euro.net]
> When using python to pipe some source code like so:
>
> cat test.py | python - foo bar
>
> it doesn't give the arguments foo and bar too test.py but thinks
> it is another source file, resulting in a file not found error.

I agree this seems wrong.  For the short term, you can do:

    cat test.py | python -- - foo bar

test.py then sees:

    ['-', 'foo', 'bar']

in sys.argv, so just ignore sys.argv[0] when it's "-".