![](https://secure.gravatar.com/avatar/d901d6ca8237fd098c391b2689755bdb.jpg?s=120&d=mm&r=g)
I am trying to remember and reconstruct what I am talking about. I found the original message and it shows I was using ipython3 sys.argv holds a different value under ipython3 and python3. The documentation of python 3.6.10 regarding argument parsing does indeed match what you report for python3. But it behaves differently for ipython3. At least while using it interactively. But also in script processing I just tried the following script ----- begin script import sys print("argument parsing") print(sys.argv) ------- end script script processing under ipython3 does following $ ipython3 argument-parsing.py argument parsing ['/media/guy/6C62-3B50/guy/Projecten/Computer/programmeren/python/argument-parsing.py'] script processing under python3 does following $ python3 argument-parsing.py argument parsing ['argument-parsing.py'] If one is aware of the difference one can compensate for it. I currently do not have space in my life and my head to further pursuit this or programming. So I will leave at this. The documentation is correct but their is a difference in argument parsing for python 3.8 and ipython3 version 7.13.0 That can lead to errors. At least in this specific trial and for these versions specified. On 4/06/2021 16:06, Julien Palard wrote:
Hi, you're quoting a long paragraph, I don't know what's wrong in it, let's try:
Le 3/14/21 à 8:48 PM, guyrenebongers71 via docs a écrit :
it reads : when no script and no arguments are given, sys.argv[0] is an empty string. $ python
import sys sys.argv [''] # This one looks OK
When the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'. $ echo "print(__import__('sys').argv)" | python - ['-'] # This one looks OK too.
When -c command is used, sys.argv[0] is set to '-c'. $ python -c 'print(__import__("sys").argv)' ['-c'] # This one is OK too.
When -m module is used, sys.argv[0] is set to the full name of the located module. $ echo "print(__import__('sys').argv)" > argv.py $ python -m argv ['/tmp/argv.py']
Maybe this one? "full name" could be written "full path"?
Options found after -c command or -m module are not consumed by the Python interpreter’s option processing but left in sys.argv for the command or module to handle. $ python -c "print(__import__('sys').argv)" foo bar ['-c', 'foo', 'bar'] # This one is true too.
$ python -m argv foo bar ['/home/mdk/clones/python/python-docs-fr/argv.py', 'foo', 'bar'] # This one is true too.
OOOhhhhhh I think I understand, you tried with ipython, not python, in which case it's the IPython documentation that should tell it's the full path, not the Python documentation, an I right?
Bests, -- [Julien Palard](https://mdk.fr)
participants (1)
-
Guy René Bongers