[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to pass Python command line options (vs arguments) when running script directly vs via Python interpreter?

David Raymond <David.Raymond at tomtom.com> writes:

> So what are you saying is an option vs an argument? Because I see no
> distinction whatsoever.

The command-line conventions do recognise the distinction.

* A command-line argument specifies input to the program.

  For example, the destination file for a ?cp? command is specified as
  the final argument to that command.

* A command-line option specifies a modifier to the program's behaviour.

  For example, the ?--force? option for a ?cp? command modifies the
  behaviour to remove the destination file if it already exists.

> When you run something you give it a bunch of strings.

Sure, command-line arguments and options are specified as strings. That
doesn't erase the distinction; it just means there is a category they
both belong to.

> That's it.

You can claim to not see the distinction, but that's athwart existing
convention, and you'll need to accept that there *is* such a distinction
in the specification of a great many programs.

> There is nothing magical about putting a dash in front of a letter,

Convention is not magical, true. Specifying options with a leading
hyphen is arbitrary.

That doesn't make it meaningless; the convention exists and is very


 \              ?In the long run, the utility of all non-Free software |
  `\      approaches zero. All non-Free software is a dead end.? ?Mark |
_o__)                                                    Pilgrim, 2006 |
Ben Finney