Python Forum
feature request: ternary fallthroughs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
feature request: ternary fallthroughs
#8
(May-05-2021, 07:02 PM)rexrf Wrote: heres what is happening:
val = int(sys.argv[1]) if int(sys.argv[1]) else fallthrough
if sys.argv[1] is not convertable to int it will not reach the if part at all because you will get exception.
Not to mention that converting to int twice is redundant. try/except is much cleaner and idiomatic.

As a side note, the 57 lines in your example can be shortned to ~ 20 if done properly - there is a lot of redundant code
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
feature request: ternary fallthroughs - by rexrf - May-05-2021, 12:57 PM
RE: feature request: ternary fallthroughs - by buran - May-05-2021, 07:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python on a ternary computer Skaperen 0 1,616 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