Command line arguments

I am a beginner at Python and am wondering what is the absolute fastest way to get command line arguments into the script. I am trying to build it for speed.

commandline$ python3.7 arg1 arg2 arg3

All I need is those args assigned to a variable so I can use them later on in the script. I don’t need any help guide or anything else as the script is for my own use.

Thank you

The raw string tokens are available via sys.argv, but many find using either argparse or even something like click easier to use as things get complex.

If the arguments are mainly for specifying files to be opened (rather than options for your script), looking at fileinput might be useful.

$ python3 -c "import sys; print(sys.argv)" arg1 arg2 arg3
['-c', 'arg1', 'arg2', 'arg3']

These come from sys.argv. See the docs for the sys module:

Cameron Simpson