Hello I start off this email with wishing everybody a good health.
The documentation python tutorial release 3.6.10 has got an error.
paragraph 2.1.1 Argument parsing
it reads : when no script and no arguments are given, sys.argv[0] is an empty string. When the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'. When -c command is used, sys.argv[0] is set to '-c'. When -m module is used, sys.argv[0] is set to the full name of the located module. 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.
That should be sys.argv[1]. sys.argv[0] gives the full path of the interpreted used. An example: In [2]: print(sys.argv) ['/usr/bin/ipython3', '-c', 'print("data")', '-i']
I used python 3.8.5 ------------------------------------------------------
Sent with [ProtonMail](https://protonmail.com) Secure Email.
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)