Hello all,
I wrote this function to recurse through a tree structure of Nodes
connected by Branches.
I use a local variable seen_nodes to mark off Nodes already seen by the
function (i.e. add them to a list).
What is puzzling me is that the local variable seen_nodes seems to be
made global
Hi Andrew,
> it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT
> to is_terminal and appending values to it.
That, I understand. I already saw in the archives this confuses many
people, e.g. the thread "Odd behavior regarding a list". I think this is
understandable if you
Hi Diez,
Great, this totally clears it up. Thank you!
- daniel
On Thu, 26 Mar 2009 17:50:20 +0100, Diez B. Roggisch wrote:
>
> That's not a local variable, that is a default argument. Which is in
> fact only created once for each function, yes.>
> http://effbot.org/pyfaq/why-are-default-value
Hi Peter,
> Plus, it works as expected (read: modifies the argument) if you
> explicitly pass an empty list to the function...
That is not so. The reason is given by Andrew Cooke in this thread.
I would "expect" that when function calls lower in the recursion
hierarchy return, the object is not