From bf609e4a30eb267a8f7a47965986b8398df210fd Mon Sep 17 00:00:00 2001 From: eficas <> Date: Tue, 8 Mar 2005 13:41:57 +0000 Subject: [PATCH] =?utf8?q?PN=20:=20m=C3=A9nage=20dans=20la=20classe=20para?= =?utf8?q?m=C3=A8tre?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Extensions/parametre.py | 71 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/Extensions/parametre.py b/Extensions/parametre.py index d20b44fa..399a9063 100644 --- a/Extensions/parametre.py +++ b/Extensions/parametre.py @@ -70,6 +70,34 @@ class PARAMETRE : print "******* Probleme : pas de valeur négative" return None + def __add__(self,a): + try : + return self.valeur+a.valeur + except : + print "******* Probleme : a l addition" + return None + + def __radd__(self,a): + try : + return self.valeur+a.valeur + except : + print "******* Probleme : a l addition" + return None + + def __sub__(self,a): + try : + return self.valeur - a.valeur + except : + print "******* Probleme : a la soustraction" + return None + + def __rsub__(self,a): + try : + return a.valeur - self.valeur + except : + print "******* Probleme : a la soustraction" + return None + def __mul__(self,a): try : return self.valeur*a.valeur @@ -84,6 +112,48 @@ class PARAMETRE : print "******* Probleme : a la multiplication" return None + def __mul__(self,a): + try : + return self.valeur*a.valeur + except : + print "******* Probleme : a la multiplication" + return None + + def __rmul__(self,a): + try : + return self.valeur*a.valeur + except : + print "******* Probleme : a la multiplication" + return None + + def __add__(self,other): + try : + return self.valeur+other + except : + print "******* Probleme : a l addition" + return None + + def __radd__(self,other): + try : + return self.valeur+other + except : + print "******* Probleme : a l addition" + return None + + def __sub__(self,other): + try : + return self.valeur - other + except : + print "******* Probleme : a la soustraction" + return None + + def __rsub__(self,other): + try : + return other - self.valeur + except : + print "******* Probleme : a la soustraction" + return None + def __mul__ (self,other): retour=None try : @@ -107,7 +177,6 @@ class PARAMETRE : return retour - def interprete_valeur(self,val): """ Essaie d'interpréter val (chaîne de caractères)comme : -- 2.39.2