osdir.com


[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?


On Wed, Aug 15, 2018 at 9:22 AM, Thomas Jollans <tjol at tjol.eu> wrote:
>
> If you really want to, you can pass a *single* argument in your #! line,
> e.g.:
>
> #!/usr/bin/python3 -Wd

This works for options that can be grouped into a single argument.
Multiple -X options aren't supported, nor is combining a -X option
with other options.

Using a shebang also works in Windows if .py files are associated with
the py.exe launcher, which can handle multiple arguments in the
shebang instead of just one.