Challenging argparse with keyword dest="class"

2025-12-29 Thread Schimon Jehudah via Python-list
Greetings, one and all. I am experimenting with module argparse. I would be glad to know of your opinions about this concern. Notice dest="class". Python software --- from argparse import ArgumentParser parser = ArgumentParser(description="Slixfeed OSTN news service setup.") pars

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Schimon Jehudah via Python-list
This is also so with "import". VARIABLE.import Schimon On Mon, 29 Dec 2025 22:50:41 +1100 Chris Angelico via Python-list wrote: > On Mon, 29 Dec 2025 at 22:47, Peter J. Holzer > wrote: > > As for the error message, I agree that "SyntaxError: invalid > > syntax" is a pretty uninformative messa

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Peter J. Holzer
On 2025-12-29 14:32:52 +0200, Schimon Jehudah via Python-list wrote: > This is also so with "import". > > VARIABLE.import And "from" and many others. Not all keywords, though. Newer keywords are "soft". They are only recognized as keywords if they appear in a position where they actually make se

Re: Python

2025-12-29 Thread Carlos E.R.
On 2025-12-21 05:08, rbowman wrote: On Sat, 20 Dec 2025 04:01:01 -0500, c186282 wrote: I load MC on EVERYTHING by default - and it COMES IN USEFUL more than enough to be worth it. I'll take your word for it. I haven't used in a couple of decades and only vaguely remember how it works.

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Peter J. Holzer
On 2025-12-29 22:50:41 +1100, Chris Angelico via Python-list wrote: > On Mon, 29 Dec 2025 at 22:47, Peter J. Holzer wrote: > > As for the error message, I agree that "SyntaxError: invalid syntax" is > > a pretty uninformative message. Python error messages in general have > > become very good over

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Chris Angelico via Python-list
On Tue, 30 Dec 2025 at 01:57, Peter J. Holzer wrote: > > On 2025-12-29 22:50:41 +1100, Chris Angelico via Python-list wrote: > > On Mon, 29 Dec 2025 at 22:47, Peter J. Holzer wrote: > > > As for the error message, I agree that "SyntaxError: invalid syntax" is > > > a pretty uninformative message.

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Chris Angelico via Python-list
On Mon, 29 Dec 2025 at 20:40, Schimon Jehudah via Python-list wrote: > (Pdb) args.class > *** SyntaxError: invalid syntax > (Pdb) > You can use getattr(args, "class") if you like (this works for all objects). But it's probably easier to dodge the issue by changing the spelling of the destination.

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Lulika Vith via Python-list
Yes—the answer to the problem is right there in the question itself. Please avoid using Python reserved keywords such as class as identifiers. Your argparse code has in fact worked correctly: it successfully created an attribute named class on the args object, but you cannot access it using dot

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Peter J. Holzer
On 2025-12-29 11:28:27 +0200, Schimon Jehudah via Python-list wrote: > Greetings, one and all. > > I am experimenting with module argparse. > > I would be glad to know of your opinions about this concern. > > Notice dest="class". Your problem has nothing to do with argparse. This is a property

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Schimon Jehudah via Python-list
Chris and Lulika. Thank you for your help. Would not it be appropriate by argparse to deny (i.e. raise an error) attempts to allocate a reserved keyword as destnation (i.e. "dest")? Regards, Schimon -- https://mail.python.org/mailman3//lists/python-list.python.org

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Peter J. Holzer
On 2025-12-29 12:11:04 +0200, Schimon Jehudah via Python-list wrote: > Would not it be appropriate by argparse to deny (i.e. raise an error) > attempts to allocate a reserved keyword as destnation (i.e. "dest")? I'm not convinced. It wouldn't actually help you except by possibly making the error m

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Chris Angelico via Python-list
On Mon, 29 Dec 2025 at 22:47, Peter J. Holzer wrote: > As for the error message, I agree that "SyntaxError: invalid syntax" is > a pretty uninformative message. Python error messages in general have > become very good over the last few years, so that feels like a bit of a > throwback. I think it w

Re: Challenging argparse with keyword dest="class"

2025-12-29 Thread Schimon Jehudah via Python-list
Peter. Good afternoon. On Mon, 29 Dec 2025 10:54:33 +0100 "Peter J. Holzer" wrote: > On 2025-12-29 11:28:27 +0200, Schimon Jehudah via Python-list wrote: > > Greetings, one and all. > > > > I am experimenting with module argparse. > > > > I would be glad to know of your opinions about this con

Annoyance building python from source

2025-12-29 Thread Keith Thompson via Python-list
When I build Python from source, the "sudo make install" step creates root-owned files in the build directory. I have not seen this while building other open-source packages from source. Is there a way to avoid this, so no root-owned files are creates other than under the target installation dire