Permalink
Browse files

Added __str__, __unicode__, __eq__, and __ne__ magic methods to resul…

…ts lists.
  • Loading branch information...
1 parent 33ad071 commit 7ed8d700da04ff2bc5e510f2dbbe85ad3348dfcf @eykd committed Aug 23, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 blueprint/dice.py
View
@@ -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))
@@ -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.

0 comments on commit 7ed8d70

Please sign in to comment.