Skip to content

Instantly share code, notes, and snippets.

@nara-l
Last active May 22, 2018 18:49
Show Gist options
  • Save nara-l/88a626799166788a77acd7a0c93fc095 to your computer and use it in GitHub Desktop.
Save nara-l/88a626799166788a77acd7a0c93fc095 to your computer and use it in GitHub Desktop.
What does 'pass' return in python?
# if pass returns it returns <NoneType> !None <str>, Explained: https://stackoverflow.com/a/36622862/851056
def f():
pass
def g(x):
if x > 2:
return x
def h():
return None
''' Usage '''
f() # None
g(3) # 3 -> we explicitely say `return x`
g(1) # None -> no return specified for that path
h() # None -> we explicitely say `return None`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment