Skip to content

Commit

Permalink
Added __str__, __unicode__, __eq__, and __ne__ magic methods to resul…
Browse files Browse the repository at this point in the history
…ts lists.
  • Loading branch information
deyk committed Aug 23, 2012
1 parent 33ad071 commit 7ed8d70
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions blueprint/dice.py
Expand Up @@ -12,6 +12,12 @@ class results(list):
def __int__(self):
return int(sum(self))

def __str__(self):
return str(int(self))

def __unicode__(self):
return unicode(int(self))

def __hash__(self):
return hash(int(self))

Expand Down Expand Up @@ -45,6 +51,12 @@ def __div__(self, b):
def __rdiv__(self, a):
return a / self._convert(a)

def __eq__(self, b):
return b == self._convert(b)

def __ne__(self, b):
return b != self._convert(b)


def dcompile(dice_expr):
"""Compile the given dice expression into a code object.
Expand Down

0 comments on commit 7ed8d70

Please sign in to comment.