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

2018-08-16 Thread Thomas Jollans
On 2018-08-16 14:33, Chris Angelico wrote: > On Thu, Aug 16, 2018 at 8:32 PM, Thomas Jollans wrote: >> On 2018-08-16 01:05, Chris Angelico wrote: >>> On Thu, Aug 16, 2018 at 8:51 AM, Cameron Simpson wrote: And as an additional alternative, when I want something weird (extra python args

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

2018-08-16 Thread Chris Angelico
On Thu, Aug 16, 2018 at 8:32 PM, Thomas Jollans wrote: > On 2018-08-16 01:05, Chris Angelico wrote: >> On Thu, Aug 16, 2018 at 8:51 AM, Cameron Simpson wrote: >>> And as an additional alternative, when I want something weird (extra python >>> args or the like) I usually make my script.py into a

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

2018-08-16 Thread Thomas Jollans
On 2018-08-16 01:05, Chris Angelico wrote: > On Thu, Aug 16, 2018 at 8:51 AM, Cameron Simpson wrote: >> And as an additional alternative, when I want something weird (extra python >> args or the like) I usually make my script.py into a module and invoke it >> via a shell script, eg: >> >>

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

2018-08-15 Thread Ben Finney
David Raymond 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

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

2018-08-15 Thread Malcolm Greene
Thanks to everyone who contributed to this thread. Great feedback and suggestions! - Malcolm -- https://mail.python.org/mailman/listinfo/python-list

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

2018-08-15 Thread Chris Angelico
On Thu, Aug 16, 2018 at 8:51 AM, Cameron Simpson wrote: > And as an additional alternative, when I want something weird (extra python > args or the like) I usually make my script.py into a module and invoke it > via a shell script, eg: > > #!/bin/sh > exec /particular/python python-opts... -m

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

2018-08-15 Thread Cameron Simpson
On 15Aug2018 20:54, eryk sun wrote: On Wed, Aug 15, 2018 at 9:22 AM, Thomas Jollans 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

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

2018-08-15 Thread eryk sun
On Wed, Aug 15, 2018 at 9:22 AM, Thomas Jollans 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

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

2018-08-15 Thread David Raymond
the more difficult method of "muck about with the OS's convenience method to get it to do something magical." -Original Message- From: Python-list [mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of Malcolm Greene Sent: Tuesday, August 14, 2018 7:47 PM

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

2018-08-15 Thread Thomas Jollans
On 14/08/18 23:45, Malcolm Greene wrote: > When you run a script via "python3 script.py" you can include command > line options like -b, -B, -O, -OO, etc between the "python3" interpreter > reference and the script.py file, eg. "python3 -b -B -O -OO script.py". > When you create a script that is

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

2018-08-14 Thread Malcolm Greene
> You might try: > from getopt import getopt > or the (apparently newer): > from optparse import OptionParser Thanks Mike. My question was trying to make a distinction between Python options (flags that precede the script or module name) and arguments (the script specific values passed on the

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

2018-08-14 Thread Malcolm Greene
> If you run the script directly, by entering >script.py or clicking a script > icon or name in File Explorer, it runs python without python options *other > than those specified in environmental variables*. Understood. I thought there might have been a way to pass Python option values via a

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

2018-08-14 Thread Michael F. Stemper
On 2018-08-14 16:45, Malcolm Greene wrote: > When you run a script via "python3 script.py" you can include command > line options like -b, -B, -O, -OO, etc between the "python3" interpreter > reference and the script.py file, eg. "python3 -b -B -O -OO script.py". > When you create a script that is

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

2018-08-14 Thread Terry Reedy
On 8/14/2018 5:45 PM, Malcolm Greene wrote: When you run a script via "python3 script.py" you can include command line options like -b, -B, -O, -OO, etc between the "python3" interpreter reference and the script.py file, eg. "python3 -b -B -O -OO script.py". More generally, python script.py

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

2018-08-14 Thread Malcolm Greene
When you run a script via "python3 script.py" you can include command line options like -b, -B, -O, -OO, etc between the "python3" interpreter reference and the script.py file, eg. "python3 -b -B -O -OO script.py". When you create a script that is executable directly, eg. script.py with execution