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 (or none) 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

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -