Python Forum
feature request: ternary fallthroughs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
feature request: ternary fallthroughs
#6
first of all int(sys.argv[1]) if int(sys.argv[1] doesn't make sense at all. Also note that it will fail if sys.argv[1] is '0', because 0 is False

And I disagree with

(May-05-2021, 12:57 PM)rexrf Wrote: It's almost like a try block but I feel like it reads better...

EAFP
: “it’s easier to ask for forgiveness than permission vs LYBL, Look before you leap
see
https://devblogs.microsoft.com/python/id...rsus-lbyl/

(May-05-2021, 06:34 PM)rexrf Wrote: A fallthrough statement transfers control to the next case.

Still unclear what the next case is... If sys.argv[1] cannot be converted to int (and raise an exception) or even if it doesn't raise an exception there is no other case that I see.

Finally - I understand that your example is more general, but just to mention that using sys.argv is the most primitive CLI arguument handling. There is argparse or even third party packages like click that make handling, parsing and validation of CLI arguments easy.
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, 06:55 PM

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