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

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -