A function that returns None, simply returns, or allows execution to reach the end of the function is basically the same.
Consider the following functions:
def func1():
return None
def func2():
pass
def func3():
return
If now we delete the function bytecode (the module discan do this), we see the following
func1():
2 0 LOAD_CONST 0 (None)
3 RETURN_VALUE
func2():
5 0 LOAD_CONST 0 (None)
3 RETURN_VALUE
func3():
8 0 LOAD_CONST 0 (None)
3 RETURN_VALUE
The functions are identical. Thus, you cannot distinguish between them, even by checking the functions themselves.
source
share