Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the exact term for 'argv' in python?

I am currently trying to grasp the exact name of argv function (if it can be called a function) that can be imported from sys or system-specific parameters. I found 3 definitions:

  • argument vector
  • argument value
  • argument variable

So which one is it? Perhaps it doesn't matter how one calls it? Does it even have an accepted name?

Thanks everyone!

like image 696
tentkl Avatar asked Mar 07 '23 19:03

tentkl


2 Answers

It doesn't really matter. It's a list (not a function), and the name argv is just borrowed from the conventional name used in C. Most of the time, you are better off using a library like argparse to process the command line arguments, in which case you won't even be using sys.argv directly.

like image 114
chepner Avatar answered Mar 21 '23 03:03

chepner


argv is a variable (a list of arguments), and is therefore not a function.

The naming seems to come from conventions used in C, which uses argc (argument count) and argv (argument vector). See also https://stackoverflow.com/a/3024202/693140

like image 26
Stefan Kögl Avatar answered Mar 21 '23 04:03

Stefan Kögl