On 03/23/2013 10:35 AM, Robert Sjoblom wrote:
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
> 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
On 03/23/2013 12:08 AM, Robert Sjoblom wrote:
You already got lots of good answers. But I want to explicitly point
out a bug in your code (2 places) that was only indirectly mentioned.
class Outcome():
def __init__(self, name): #Ignoring odds for now
self.name = name
def
On 23/03/13 04:08, Robert Sjoblom wrote:
However, if I were to create a class without the __eq__ and __ne__
definitions, what is to prevent me from doing: a.name == b.name ? Or
am I missing something in my implementation of the overrides? Is there
a reason why I shouldn't do .name comparisons?
It is also good to know that overriding the "comparison magic methods" in
your class can be very useful if you wish to apply sorting/searching
procedures available in python.
If you also implement __gt__, __lt__, __ge__, __le__ in your class, then
you can append each of your objects to a list an
On 23/03/13 15:08, Robert Sjoblom wrote:
Hi list. I'll preface this by saying that I am very grateful for all
of you, and thank you in advance to anyone that answers.
I'm currently working on a roulette simulator, because it seemed like
fun. I found out I needed a way to compare two different ou
On 03/23/2013 12:08 AM, Robert Sjoblom wrote:
Hi list. I'll preface this by saying that I am very grateful for all
> of you, and thank you in advance to anyone that answers.
>
> I'm currently working on a roulette simulator, because it seemed like
> fun. I found out I needed a way to compare tw
Hi list. I'll preface this by saying that I am very grateful for all
of you, and thank you in advance to anyone that answers.
I'm currently working on a roulette simulator, because it seemed like
fun. I found out I needed a way to compare two different outcomes, and
it was suggested to me that I s