[Tutor] Overriding equality tests in Python

Robert Sjoblom robert.sjoblom at gmail.com
Sat Mar 23 15:35:53 CET 2013


> As I said, I don't really understand why a roulette outcome has a name in
> the first place, but given that it does, I don't any problem with comparing
> the names directly. Still, I would probably write it as an __eq__ method,
> since it's easier to write a == b than a.name == b.name.
I figured that it would be easier if outcomes had names. Consider that
each Bin (where the ball lands) can contain between 2 to 14 different
winning outcomes. Each Bin() collects various Outcome()s, each
Outcome() handles the amount won. Consider the '1' Bin, it contains
the following winning Outcome()s:
 “1”, “Red”, “Odd”, “Low”, “Column 1”, “Dozen 1-12”, “Split 1-2”,
“Split 1-4”, “Street 1-2-3”, “Corner 1-2-4-5”, “Five Bet”, “Line
1-2-3-4-5-6”, “00-0-1-2-3”, “Dozen 1”. All of these bets will payoff
if the wheel spins a “1”.

I'm almost done with the Outcome() class (just writing the unittests
for it), after that I'll tackle the Bin class, at which point I will
definitely return for more questions. As I said before, thanks to
everyone who answered.
-- 
best regards,
Robert S.


More information about the Tutor mailing list