recursive function return value problems
Brian L. Troutwine
goofyheadedpunk at gmail.com
Wed Dec 28 18:55:53 EST 2005
randomtalk at gmail.com wrote:
>>>>def reTest(bool):
>
> ... result = []
> ... if not bool:
> ... reTest(True)
> ... else:
> ... print "YAHHH"
> ... result = ["should be the only thing returned"]
> ... print "printing result: "
> ... print result
> ... return result
> ...
>
>>>>reTest(False)
You're both printing the result and returning it. The interpreter just
happens to show both printed and returned variables.
An example of a shown return variable:
>>>def returnb():
... return 'b'
...
>>>returnb()
'b'
Hope that helps,
Brian
--
What if the Universe were a chrooted environment with everything
symlinked from the host?
More information about the Python-list
mailing list