Saturday, 7 September 2013

print value before return

print value before return

I have a python function
def foo():
'''
some code
'''
return handle.fetch_some_result()
and I want to achieve the goal:
def foo():
'''
some code
'''
value = handle.fetch_some_result()
print value
return value
So how can I achieve this but not use the above code(a little ugly).
Are there some elegant ways to do that but not use the middle var(value)
or is it possible in python?
Thx!

No comments:

Post a Comment