[New-bugs-announce] [issue17297] Issue with return in recursive functions

Luis López Lázaro report at bugs.python.org
Mon Feb 25 19:17:37 CET 2013


New submission from Luis López Lázaro:

Sorry if I am raising something naive as perhaps I am doing something wrong as I am both an amateur programmer and a newcomer to Python, but version 3.3 appears to have an issue with the return statement in the setting of recursive functions.

When implementing a fruitful recursive function in Python 3.3 (specifically Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32) which depends on conditionals it only returns the result value if the conditions are met in the first iteration.

I am attaching a file in which I have implemented the Euclidean algorithm in 2 slightly different ways. The print statements produce the expected results (for instance with 1000,75) and a print statement placed in the if loop where the return statement is shows the indicator sentence but no value is returned by the function. I have also copied an implementation obtained from a website (function Euclid_LP; obtained from the wiki Literate Programs, http://en.literateprograms.org/Euclidean_algorithm_%28Python%29) and it does not work either.

For the tests, initially I run the program with F5 and invoked the functions from the Python shell. Later I have added a main part of the program prompting for the numbers and calling the functions to later display the results, with no change in the outcome

----------
components: Regular Expressions
files: Chapter 6 MCD Euclidean.py
messages: 182966
nosy: ezio.melotti, luislopezlazaro, mrabarnett
priority: normal
severity: normal
status: open
title: Issue with return in recursive functions
versions: Python 3.3
Added file: http://bugs.python.org/file29236/Chapter 6 MCD Euclidean.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17297>
_______________________________________


More information about the New-bugs-announce mailing list