What does return with nothing mean in python? -
i'm viewing source code of project now. in saw function this.
def func(x): if condition_a: return if condition_b: return process_something
what return nothing here?
the "return
nothing" exits function @ line , returns none
. python's docs say:
if expression list present, evaluated, else
none
substituted.
return
leaves current function call expression list (ornone
) return value.
in flow control, i've seen commonly used when sort of condition encountered makes impossible execute rest of function; example,
def getdatafromserver(): if servernotresponding(): return # important stuff here requires server running
Comments
Post a Comment