first of all
And I disagree with
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/
Still unclear what the next case is... If
Finally - I understand that your example is more general, but just to mention that using
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 FalseAnd 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
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs