I understand we all want to be helpful and friendly, but it seems to me that helping someone use the wrong tool for the job isn$B!G(Bt really helpful in the long run.
argparse is for parsing command line arguments. It$B!G(Bs the wrong tool for this job.
As Chris Angelico already said: This entire thread is a massive "how can I use X to do Y?" problem.
From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Thomas Passin <list1@tompassin.net>
Date: Tuesday, January 24, 2023 at 10:23 AM
To: Mike Baskin <mikebaskin6538@yahoo.com>, python-list@python.org <python-list@python.org>
Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
On 1/24/2023 10:13 AM, Mike Baskin wrote:
> Can you stop please
It's way past time, isn't it!
> Sent from Yahoo Mail for iPhone <https://urldefense.com/v3/__https://overview.mail.yahoo.com/?.src=iOS__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIyHt-2PcA$ >
>
> On Tuesday, January 24, 2023, 10:12 AM, Thomas Passin
> <list1@tompassin.net> wrote:
>
> On 1/23/2023 9:12 PM, Chris Angelico wrote:
> > On Tue, 24 Jan 2023 at 13:09, Jach Feng <jfong@ms4.hinet.net
> <mailto:jfong@ms4.hinet.net>> wrote:
> >>
> >> Chris Angelico $B:_(B 2023$BG/(B1$B7n(B24$BF|(B $B@14|Fs@6Zo(B5:00:27 [UTC+8] $BE*?.Cf(B
> $BUmF;!'(B
> >>> On Tue, 24 Jan 2023 at 07:47, Cameron Simpson <c...@cskk.id.au
> <mailto:c...@cskk.id.au>> wrote:
> >>>>
> >>>> But for Jach Feng: the "--" is really expected as something
> the user
> >>>> does when they invoke your programme, _explicitly_ saying that
> what
> >>>> follows from here is not an argument. So the user is expected
> to type:
> >>>>
> >>>> your_script -x -y -- "-4^2+5.3*abs(-2-1)/2"
> >>>>
> >>>> where there are -x and -y options, then end of options, then an
> >>>> argument, which would look like an option if there wasn't the "--"
> >>>> argument.
> >>> And if you DON'T expect the user to enter the "--", then why use
> >>> argparse? You can just check argv directly to get your arguments.
> >>>
> >>> This entire thread is a massive "how can I use X to do Y?" problem.
> >>>
> >>> ChrisA
> >> The '--' requirement makes its usage less instinctive, and
> handling argv directly makes me loss the benefit of using '-h':-)
> >
> > if "-h" in sys.argv: usage()
> > else: do_stuff_with(sys.argv[1:])
> >
> > What is argparse really doing for you?
>
> I second this. "if '-h' in sys.argv:" is usually what I do.
>
> Alternatively, you could use "--arg=" syntax and place your string
> "-4^2+5.3*abs(-2-1)/2" its right-hand side":
>
> infix2postfix [options] "--infix=-4^2+5.3*abs(-2-1)/2"
>
> This shouldn't be too hard for a user to work with. You could scan the
> argument list for the presence of "--infix=" and display the help
> message if it isn't there.
>
>
> --
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$>
> <https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$ >
>
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$>
--
https://mail.python.org/mailman/listinfo/python-list
argparse is for parsing command line arguments. It$B!G(Bs the wrong tool for this job.
As Chris Angelico already said: This entire thread is a massive "how can I use X to do Y?" problem.
From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of Thomas Passin <list1@tompassin.net>
Date: Tuesday, January 24, 2023 at 10:23 AM
To: Mike Baskin <mikebaskin6538@yahoo.com>, python-list@python.org <python-list@python.org>
Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
On 1/24/2023 10:13 AM, Mike Baskin wrote:
> Can you stop please
It's way past time, isn't it!
> Sent from Yahoo Mail for iPhone <https://urldefense.com/v3/__https://overview.mail.yahoo.com/?.src=iOS__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIyHt-2PcA$ >
>
> On Tuesday, January 24, 2023, 10:12 AM, Thomas Passin
> <list1@tompassin.net> wrote:
>
> On 1/23/2023 9:12 PM, Chris Angelico wrote:
> > On Tue, 24 Jan 2023 at 13:09, Jach Feng <jfong@ms4.hinet.net
> <mailto:jfong@ms4.hinet.net>> wrote:
> >>
> >> Chris Angelico $B:_(B 2023$BG/(B1$B7n(B24$BF|(B $B@14|Fs@6Zo(B5:00:27 [UTC+8] $BE*?.Cf(B
> $BUmF;!'(B
> >>> On Tue, 24 Jan 2023 at 07:47, Cameron Simpson <c...@cskk.id.au
> <mailto:c...@cskk.id.au>> wrote:
> >>>>
> >>>> But for Jach Feng: the "--" is really expected as something
> the user
> >>>> does when they invoke your programme, _explicitly_ saying that
> what
> >>>> follows from here is not an argument. So the user is expected
> to type:
> >>>>
> >>>> your_script -x -y -- "-4^2+5.3*abs(-2-1)/2"
> >>>>
> >>>> where there are -x and -y options, then end of options, then an
> >>>> argument, which would look like an option if there wasn't the "--"
> >>>> argument.
> >>> And if you DON'T expect the user to enter the "--", then why use
> >>> argparse? You can just check argv directly to get your arguments.
> >>>
> >>> This entire thread is a massive "how can I use X to do Y?" problem.
> >>>
> >>> ChrisA
> >> The '--' requirement makes its usage less instinctive, and
> handling argv directly makes me loss the benefit of using '-h':-)
> >
> > if "-h" in sys.argv: usage()
> > else: do_stuff_with(sys.argv[1:])
> >
> > What is argparse really doing for you?
>
> I second this. "if '-h' in sys.argv:" is usually what I do.
>
> Alternatively, you could use "--arg=" syntax and place your string
> "-4^2+5.3*abs(-2-1)/2" its right-hand side":
>
> infix2postfix [options] "--infix=-4^2+5.3*abs(-2-1)/2"
>
> This shouldn't be too hard for a user to work with. You could scan the
> argument list for the presence of "--infix=" and display the help
> message if it isn't there.
>
>
> --
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$>
> <https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$ >
>
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!g3YRQIW4wminyTVpjV9kATW-QRZ1YhvDi82oJvatyhNe_OABSPTU9c8KIOlztBNofs690OPwUdIykR5ILj4$>
--
https://mail.python.org/mailman/listinfo/python-list