Puzzling: local variable in recursive function made global?
MRAB
google at mrabarnett.plus.com
Thu Mar 26 15:03:26 EDT 2009
andrew cooke wrote:
> it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT
> to is_terminal and appending values to it.
>
> instead, make a new copy:
>
> branch.next.is_terminal(list(seen_nodes))
>
> sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE
> ANY MORE.
>
[snip]
Perhaps as part of the Google Summer of Code you should write a script
that analyses the posts in this newsgroup and replies automatically to
such posts. :-)
More information about the Python-list
mailing list