Cutton Eye
Cutton Eye

Reputation: 3559

pass command line arguments to python interpreter without a script file

I want do start the python interpreter and debug with sys.argv. I do not want to provide a python file. If I provide a file, the interpreter executes the file and finishes.

Is there a way to archive this?

python argA argB
...
>>> import sys
>>> print sys.argv
['argA','argB']

Upvotes: 6

Views: 1313

Answers (1)

brunns
brunns

Reputation: 2764

This is pretty much what you want:

$ python - argA argB

The first argument will show up as -, though - think of it as a pseudo script name. I don't think you can get away from that.

Upvotes: 9

Related Questions