Last active
May 22, 2018 18:49
-
-
Save nara-l/88a626799166788a77acd7a0c93fc095 to your computer and use it in GitHub Desktop.
What does 'pass' return in python?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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