How to handle empty (none) tuple returned from python function -


i have function either returns tuple or none. how caller supposed handle condition?

def nontest():   return none  x,y = nontest()  traceback (most recent call last):  file "<stdin>", line 1, in <module> typeerror: 'nonetype' object not iterable 

eafp:

try:     x,y = nontest() except typeerror:     # none-thing here or pass 

or without try-except:

res = nontest()  if res none:     .... else:     x, y = res 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -