Python Forum
New parser enabling more soft keywords
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New parser enabling more soft keywords
#1
I was reading through PEP 622 and it ocurred to me:
Would it make sense, now that there is a new parser, to change some existing hard keywords to soft ones?
For example, making "class" a soft keyword could make some code more readable... or would useing "cls" as an identifier still be better?
I do get that this may not even be desirable because it may have a big impact in other implementations.
But maybe there is another use case that could benefit from this?
Reply
#2
I'm 100% against "soft keywords". With such ideas, Python will someday be as unreadable as Perl, in the name of syntactic permissivity. By the way, I'm also against PEP 622, I don't want Python to look like Haskell either. A clear and simple syntax is one of the main reasons of Python's success. Other languages could replace it in the future if we lose this.
Reply
#3
I wasn't expecting a slipery slope fallacy argument from a forum moderator, and as the first response nonetheless, so I guess that tempers my expectations about this forum.

Snark aside, I've noticed that production code with large numbers of LOC make extensive use of isinstance which is the exact kind of problem that PEP 622 attempts to solve, and reading through all those branching ifs is not at all simple. This seems like an improvement that would benefit large codebases, and have zero impact on small projects.

What would be a better alternative to solve the lack of support for destructuring heterogeneous data, then? Since python provides no specific solution for this common problem, it invites every user to reinvent the wheel, which goes against the principle that there should ideally be "one" way to do it.
Reply
#4
arthexis Wrote:Since python provides no specific solution for this common problem,
It is not quite true. One can write generic functions through functools.singledispatch and functools.singledispatchmethod that select a function based on the first argument's type. Of course one can also use normal polymorphism for this. I think a lot of code that uses isinstance() calls in functions could be rewritten differently by using these pythonic tools.

Also such programs should be concerned about improving the code that produces the heterogeneous data. These data may come from poor design choices upstream.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  parser for LVM head Skaperen 0 1,436 Nov-02-2019, 04:04 AM
Last Post: Skaperen
  cli arguments parser Skaperen 0 2,624 Mar-21-2018, 01:41 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020