Re: [Tutor] Unexpected results with obj.method().method()

2012-12-10 Thread C M Caine
Thanks for the advice. As is often the case with these things, eryksun pointed out a stupid mistake I'd made (mutating part of an immutable class) that I should have seen. On 6 December 2012 00:50, Oscar Benjamin wrote: > On 5 December 2012 18:11, C M Caine wrote: > > Dear all, > > > > I've wr

Re: [Tutor] Unexpected results with obj.method().method()

2012-12-10 Thread C M Caine
Thanks eryksun, that was the bug. Thanks for pointing out the tabs as well, they were added by vim's autoindent. I've set expandtab for python files now. I decided to change the code such that current_player and turn_number are hidden behind properties meaning I won't overwrite them accident or st

Re: [Tutor] Unexpected results with obj.method().method()

2012-12-05 Thread eryksun
On Wed, Dec 5, 2012 at 1:11 PM, C M Caine wrote: > > The full code is on pastebin http://pastebin.com/tUh0W5Se > import game S = game.State() S1 = S.move_state(1).move_state("SWAP") S2 = S.move_state(1) S3 = S2.move_state("SWAP") S1 == S3 > False In lines 156-160 you

Re: [Tutor] Unexpected results with obj.method().method()

2012-12-05 Thread Oscar Benjamin
On 5 December 2012 18:11, C M Caine wrote: > Dear all, > > I've written a class State that subclasses tuple. The class has a method > move_state that takes a move and returns a new state object representing the > new state of the game. > > I would expect S1 and S3 to be equal on the last line here

Re: [Tutor] Unexpected results with obj.method().method()

2012-12-05 Thread C M Caine
I edited the output of Lines 109-111 from my source code out of the interpreter transcripts above, by the by. On 5 December 2012 18:11, C M Caine wrote: > Dear all, > > I've written a class State that subclasses tuple. The class has a method > move_state that takes a move and returns a new stat

[Tutor] Unexpected results with obj.method().method()

2012-12-05 Thread C M Caine
Dear all, I've written a class State that subclasses tuple. The class has a method move_state that takes a move and returns a new state object representing the new state of the game. I would expect S1 and S3 to be equal on the last line here, but they are not. >>> import game >>> S = game.State(