The way it is I can only call funct()
once per iteration. So I can't do this:
result=[funct(arg) for arg in args if arg and funct(arg)]
If there is a connection drop this function returns None
. If None is returned I don't want to add it to the resulted list. How to achieve it?
def funct(arg):
if arg%2: return arg*2
args=[1,2,3,None,4,5]
result=[funct(arg) for arg in args if arg]
print result