Python Forum
feature request: ternary fallthroughs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
feature request: ternary fallthroughs
#21
Can you point us to an example in another language that does this? I've not seen it before, so must be unfamiliar with those languages.
Reply
#22
(May-06-2021, 07:37 AM)ndc85430 Wrote: Can you point us to an example in another language that does this? I've not seen it before, so must be unfamiliar with those languages.

I'm not sure if it's worth repeating at this point, as i've run this basic principle into the ground...

here are the facts: this is a feature that is genuinely implemented and used...some people just have a hard time understanding.

please read my comments in the full example after reading this:

https://stackoverflow.com/questions/4082...ugh-or-not.
Reply
#23
I vote against the fallthrough because of import this.

Readability counts! In Python when you have this structure
if ...:
   ...
else:
   ...
you can be 100% certain that if the program runs the 'if' part, it doesn't run the 'else' part. Changing this would force the reader to examine every 'if' block to the tiniest detail. It breaks the clarity that made this language's success. No, No, No!
Reply
#24
(May-06-2021, 08:52 AM)Gribouillis Wrote: I vote against the fallthrough because of import this.

Readability counts! In Python when you have this structure
if ...:
   ...
else:
   ...
you can be 100% certain that if the program runs the 'if' part, it doesn't run the 'else' part. Changing this would force the reader to examine every 'if' block to the tiniest detail. It breaks the clarity that made this language's success. No, No, No!

Another fool blinded by pep 8.

"A foolish consistency is the hobgoblin of little minds"

the language evolves for a reason. because beautiful is better than ugly.

it's why we have python2, python3, and eventually python4.

you can quote the docs all you want, I've been hacking since windows NT 3.

change. is. inevitable. kiddo.
Reply
#25
(May-06-2021, 09:05 AM)rexrf Wrote: [quote="Gribouillis" pid='141725' dateline='1620291147']
I vote against the fallthrough because of import this.

Readability counts! In Python when you have this structure
if ...:
   ...
else:
   ...
you can be 100% certain that if the program runs the 'if' part, it doesn't run the 'else' part. Changing this would force the reader to examine every 'if' block to the tiniest detail. It breaks the clarity that made this language's success. No, No, No!

Another fool blinded by pep 8. it is a guide, not a law.

"A foolish consistency is the hobgoblin of little minds"

the language evolves for a reason. because beautiful is better than ugly.

it's why we have python2, python3, and eventually python4.

you can quote the docs all you want, I've been hacking since windows NT 3.

change. is. inevitable. kiddo.
Reply
#26
rexrf Wrote:A foolish consistency is the hobgoblin of little minds
We don't have to take every quotation as an enlightening thought. That one was coined by Ralph Waldo Emerson, a leading figure of the transcendentalism movement, a romantic american philosophical movement in the 19th century. It is not particularly my cup of tea.

There are very good reasons for the tremendous success of the Python language. To me, CLARITY is one of the main points. Let us not through away the best part of the language.
Reply
#27
(May-06-2021, 09:29 AM)Gribouillis Wrote:
rexrf Wrote:A foolish consistency is the hobgoblin of little minds
We don't have to take every quotation as an enlightening thought. That one was coined by Ralph Waldo Emerson, a leading figure of the transcendentalism movement, a romantic american philosophical movement in the 19th century. It is not particularly my cup of tea.

There are very good reasons for the tremendous success of the Python language. To me, CLARITY is one of the main points. Let us not through away the best part of the language.

My point is that taking every quotation literally is the flaw in your logic. Things change. things you believe to be true might suddenly become untrue.

You talk about readability and that is my main point. A one line eval with additional flow control is a no brainer. It is beautiful and it is readable.

you just havent seen it before.
Reply
#28
it reminds me of an old boss who hated python doggedly. I once tried to explain list / dictionary comprehensions to him and he just couldn't make heads or tails of it. despite the fact it has been implemented and enjoyed and well documented.

Fallthroughs make sense. they exist. you can read the docs. You're just being a hobgoblin
Reply
#29
Only your line doesn't work for its purpose. If you pass the string 'foo' as the first argument instead of a number, the program crashes.
Reply
#30
With structural pattern matching you can simplify things a little.
It will be introduced with Python 3.10. In Alpha and Beta it's already implemented.
I'm testing where the use of it is good and where it's bad.

def get_args(default=42):
   # sys.argv = [str, str, str, ...]
   # will never match :-D
   # nonono
   match sys.argv:
        case _, int(value):
            return value
        case _:
            return default

Works only, if len(sys.args) == 2 and the second arg must be an integer. If there is a match, value is converted to int and returned.


Edit: The example won't work because the objects in sys.argv are str. The type is checked and no conversion happens. I guess this is an example where not to use structural pattern matching. It's just testing what is useful and looks natural and what not.
ndc85430 likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python on a ternary computer Skaperen 0 1,552 Jun-20-2020, 02:21 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