Would anyone be willing to explain why the first does not work, but the second does?
In the first, the function calculates the final, adjusted value...
# returns None
def _pareRotation(degs):
if degs > 360:
_pareRotation(degs - 360)
else:
print "returning %s" % degs
return degs
...but returns None:
print _pareRotation(540)
>> returning 180
>> None
However, if we flip things a bit and return the function...
# returns expected results
def _pareRotation(degs):
if degs < 360:
print "returning %s" % degs
return degs
else:
return _pareRotation(degs - 360)
...it works as expected:
print _pareRotation(540)
>> returning 180
>> 180
Mostly, wondering what causes that None to get ejected from the recursive loop?