Re: [Tutor] OOP question

2011-01-19 Thread Nick Stinemates
If you want to test if one outcome is equal to another, you probably want to know if The name of the outcome is the same The odds of the outcome is the same So, you'd implement it like so class Outcome: def __eq__(self, other): if self.name == other.name and self.odds == other.odds:

Re: [Tutor] OOP question

2011-01-18 Thread Steven D'Aprano
Ben Ganzfried wrote: Hey guys, I'm trying to get a version of Roulette working and I had a quick question. There's a quick answer and long answer. The quick answer is, you have to refer to self.odds, not just odds. The long answer is below: Here is my code: [...] Now whenever I try to ca

Re: [Tutor] OOP question

2011-01-18 Thread Nick Stinemates
Updated inline. Check the updated definiton of winAmount. Nick On Tue, Jan 18, 2011 at 9:25 AM, Ben Ganzfried wrote: > Hey guys, > > I'm trying to get a version of Roulette working and I had a quick > question. Here is my code: > > class Outcome: > > def __init__(self, name, odds): >

[Tutor] OOP question

2011-01-18 Thread Ben Ganzfried
Hey guys, I'm trying to get a version of Roulette working and I had a quick question. Here is my code: class Outcome: def __init__(self, name, odds): self.name = name self.odds = odds def winAmount(self, amount): return odds*amount def __eq__(self, other):