Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass command line arguments to python interpreter without a script file

Tags:

python

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']
like image 552
Cutton Eye Avatar asked Jul 29 '26 22:07

Cutton Eye


1 Answers

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.

like image 192
brunns Avatar answered Jul 31 '26 11:07

brunns



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!