recursive function return value problems
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Wed Dec 28 19:13:42 EST 2005
More information about the Python-list mailing list
Wed Dec 28 19:13:42 EST 2005
- Previous message (by thread): recursive function return value problems
- Next message (by thread): recursive function return value problems
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 28 Dec 2005 16:05:30 -0800, randomtalk wrote: > the final returned value is: [] > > the two values printed is (note i only have one print statement > printing "print result",. however, in the actualality, it's printed > twice): > printing result: > ['should be the only thing returned'] > printing result: > [] > > therefore, sadly, i don't thinkg you've understand my problem > correctly.. I wonder what you think your problem is. You make TWO calls to reTest (the first one you explicitly call, then the recursive call). 'print "printing result:"' happens in *every* call to reTest, regardless of the argument, so of course it gets printed twice. What did you expect to happen? By the way, it is Bad with a capital B to shadow the names of built-in functions as you do: def reTest(bool): # don't use bool as the name of an argument! bool is a built-in type. By using that name as an argument, you now have made the built-in type inaccessible to your code, which is a potent source of hard-to-track-down bugs. -- Steven.
- Previous message (by thread): recursive function return value problems
- Next message (by thread): recursive function return value problems
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list