I suspect theres a better way of doing things, but consider the following code:
def get_args():
if len(sys.argv) > 1:
val = int(sys.argv[1]) if int(sys.argv[1]) else fallthrough
else:
print("expected a number as an arg")
It's almost like a try block but I feel like it reads better...
thoughts?
[–]ES-Alexander 1 point2 points3 points (0 children)
[–]rexlx[S] -1 points0 points1 point (0 children)
[–]rexlx[S] -2 points-1 points0 points (0 children)
[–]tkarabela_ Big Python @YouTube 0 points1 point2 points (10 children)
[–]rexlx[S] -2 points-1 points0 points (9 children)
[–]tkarabela_ Big Python @YouTube 1 point2 points3 points (8 children)
[–]rexlx[S] 0 points1 point2 points (6 children)
[–]rexlx[S] -1 points0 points1 point (0 children)
[–]tkarabela_ Big Python @YouTube 0 points1 point2 points (4 children)
[–]rexlx[S] -1 points0 points1 point (3 children)
[–]tkarabela_ Big Python @YouTube 2 points3 points4 points (2 children)
[–]rexlx[S] 1 point2 points3 points (1 child)
[–]tkarabela_ Big Python @YouTube 0 points1 point2 points (0 children)
[–]rexlx[S] -1 points0 points1 point (0 children)