Re: Challenging argparse with keyword dest="class"
"Peter J. Holzer" <[email protected]> Mon, 29 Dec 2025 12:43:06 +0100
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <fs3uywtrnejtf5jue2rzoypb7krooe4pgpmiyhejmkujw6net6@e6npq7zl6nli> |
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 message easier to understand, but it would remove some
functionality (as we've pointed out, you can access the argument, it's
just a bit less convenient - for some applications that may not matter).
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 would be generally useful to improve that message
(maybe something like "expected identfier, got reserved word 'class'").
hjp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmlSaUEACgkQ8g5IURL+ KF1p9hAAgelPuuuiwftQDZG43iDFtFIFnrXmSNNqKOhdySWVF/Cpg2mxzd/UVC9s FakKv871vYELvULddD+X0x12VEGd99nI26nYKlKn5awMqA5AJTM8RWR0mOE2oCIr ilFV2zJ5Vvi3/YhpcWzDj5e+8+JNOmSlaVPm98RowQ3aIv+5jhX+za1aCTXjHHzo wenEHv0ahTKohRl4CpRf0eYChF0By0uADnlC76pEsorPdQbp3ktXag9R1sNCp7Y3 CxvxpSRqyCE6kUAzaYNoE9w99YDwV1casvy2JgrJwXtuiTbFVOtBJhDhuKFs5l8T 1phX3Ecjz1PSW2cIAAYLaFDmAJG0sW819gntNaOjQDrCdrOsKuLRQ4pf0gsBrjIM 5BqaCJEUbSPBcKBQGL7veenqkhfyuar4S51+bfhNgOS2hEDY9ZE0o+Y4OnE3SwnW 8DpUYxybLwDJjzmcpdgnlCMGziqr+WVY3PaFscK52yXosUUzRkDmEWi5Fsrrnmk5 Z8ULm4JtryzqrmXzc4B7ScCchmyUn52yyAtL5auAHlxfxpwmFNzTu2TgPIBBZThv WXJX0KAqzwneynbWg58fsF8ob7KEDG7sdaq8kfoJsm8r0DHQdF6Z64ox+7Vc6eqr QKht6MgLOokgPVh3jEJbZil1fXJwGydSMxK/mIiiwGrO1lN9a84= =oHBR -----END PGP SIGNATURE-----