From: Christian Caremoli <> Date: Mon, 19 Nov 2007 10:19:24 +0000 (+0000) Subject: CCAR: ajout __hash__ et utilisation division spéciale pour entiers X-Git-Tag: V1_13b2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=52bf04dd94216f95d0ac1838c13e24827ef89353;p=tools%2Feficas.git CCAR: ajout __hash__ et utilisation division spéciale pour entiers --- diff --git a/Extensions/param2.py b/Extensions/param2.py index 765dd1e0..e91e3e1b 100644 --- a/Extensions/param2.py +++ b/Extensions/param2.py @@ -53,13 +53,23 @@ class Formula: def __le__( self, other ): return self.eval() <= other def __gt__( self, other ): return self.eval() > other def __ge__( self, other ): return self.eval() >= other + def __hash__(self):return id(self) + +def _div(a,b): + if isinstance(a,(int,long)) and isinstance(b,(int,long)): + if a%b: + return a/b + else: + return a//b + else: + return a/b class Binop(Formula): opmap = { '+': lambda a, b: a + b, '*': lambda a, b: a * b, '-': lambda a, b: a - b, - '/': lambda a, b: a / b, + '/': _div, '//': lambda a, b: a // b, '**': lambda a, b: a ** b, '[]': lambda a, b: a[b] ,