Skip to content

Instantly share code, notes, and snippets.

@reox
Created November 29, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/1010778e5727d99445301b9834d27c95 to your computer and use it in GitHub Desktop.
Save reox/1010778e5727d99445301b9834d27c95 to your computer and use it in GitHub Desktop.
divide by a value, decide with a flag
# What you would normaly do:
def some_divison():
flag = True
val = 23
divisor = 42
if flag:
return val / divisor
# Now the method without if:
def new_divison():
flag = 1
val = 23
divisor = 42
# if flag == 1, the division will run. If flag == 0, val is returned
return val / divisor ** flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment