[sage-support] Re: Strange behavior in Partition(x).next()

2007-12-13 Thread Carlo Hamalainen
On Dec 14, 2007 12:19 PM, mekaj <[EMAIL PROTECTED]> wrote: > Now I would expect that when I call print_partitions(x), where 'x' is > an Integer that SAGE would print all possible partitions of 'x'. The > first time I call the function it works as expected. However, for > each call after that, it

[sage-support] Re: Strange behavior in Partition(x).next()

2007-12-13 Thread mekaj
Hi David. Thanks for the quick reply :) > def get_partitions(x, y=None): > if y is None: > y = [] > [... other stuff ...] It works! I guess I'm still learning the intricacies of Python. All I had to do was the changes you suggested and then make sure to change

[sage-support] Re: Strange behavior in Partition(x).next()

2007-12-13 Thread David Harvey
On Dec 13, 2007, at 9:19 PM, mekaj wrote: > def get_partitions(x,y=[]): The problem might be your default argument above. This is really a python issue. Every time your function is called, it's getting the *same* list object. The standard python idiom to get around this is: def get_partiti