Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Karen Park
I figured it out…there was a logistics file given with the assignment! I thought it was supposed to be a download included with the python download…oops! Thanks, Karen > On Nov 27, 2022, at 9:34 PM, Skip Montanaro wrote: > >  >> >> >> ummm, hate to say this, but have you checked the

Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Skip Montanaro
> > ummm, hate to say this, but have you checked the documentation? this > case is supported using an action named 'version' without doing very much. > Thanks, Mats. I actually searched all over the argparse docs. (There's a lot to digest. Honestly, if I wasn't attempting to be sort of

Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Weatherby,Gerard
Use two parsers: import argparse import sys vparser = argparse.ArgumentParser(add_help=False) vparser.add_argument('--version',action="store_true",help="show version") # look for version, ignore remaining arguments vargs, _ = vparser.parse_known_args() if vargs.version: print("Version 2.0")

Re: Python coding

2022-11-27 Thread Dennis Lee Bieber
On Sun, 27 Nov 2022 16:47:29 -0600, Karen Park declaimed the following: >I am trying to do a python code. Using Windows, I got as far as the step that >asks me to “copy the logistics.py file and save it in the same folder that you >are running python from” (as displayed by the command prompt).

RE: Python coding

2022-11-27 Thread Mike Dewhirst
Create a folder anywhere convenient and copy it in there.Then - if python has been downloaded from the Python website and installed "normally" you can open a command prompt in that folder and type C:\\$>python logistics.py"normally" means Python is in your path environment variable.--(Unsigned

Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Mats Wichmann
On 11/27/22 16:40, Skip Montanaro wrote: I have a script to which I'd like to add a --version flag. It should print the version number then exit, much in the same way --help prints the help text then exits. I haven't been able to figure that out. I always get a complaint about the required

Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Skip Montanaro
> class VersionAction(argparse.Action): > def __call__(self, parser, namespace, values, option_string): > print(VERSION) > exit() ... > parser.add_argument("-v", "--version", nargs=0, action=VersionAction) Thanks. An action class didn't occur to me. I looked briefly at the

Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Matt Wheeler
I wondered whether subparsers might work, but they don't quite fit here. This seems to fit the bill fairly well, though I agree it would be nice if there were a neater option: import argparse import sys VERSION = 0.1 def main(args): parser.parse_args(args) class

Re: Python coding

2022-11-27 Thread Cameron Simpson
On 27Nov2022 16:47, Karen Park wrote: I am trying to do a python code. Using Windows, I got as far as the step that asks me to “copy the logistics.py file and save it in the same folder that you are running python from” (as displayed by the command prompt). Can you help direct me where to go

argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Skip Montanaro
I have a script to which I'd like to add a --version flag. It should print the version number then exit, much in the same way --help prints the help text then exits. I haven't been able to figure that out. I always get a complaint about the required positional argument. I think I could use

Python coding

2022-11-27 Thread Karen Park
Hello, I am trying to do a python code. Using Windows, I got as far as the step that asks me to “copy the logistics.py file and save it in the same folder that you are running python from” (as displayed by the command prompt). Can you help direct me where to go to copy and save this

[Python-announce] PyCA cryptography 38.0.4 released

2022-11-27 Thread Paul Kehrer
PyCA cryptography 38.0.4 has been released to PyPI. cryptography includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, asymmetric algorithms, message digests, X509, key derivation functions, and much more. We support Python 3.6+,