![](//s1.studylibfr.com/store/data-gzf/82381d6c8da0348d80e64bce520bd940/1/001975782.htmlex.zip/bg2.jpg)
Opérateurs
Orienté objets
Pour aller plus loin
●La doc de référence de la bibliothèque standard Python - http://www.python.org/doc/current/lib/lib.html
●Grand répertoire de liens pour Python - http://www.python-eggs.org/links.html
●Affectation :
a = 1
●Arithmétique :
a + b – c * d / e % f ** g
●Logique :
(not a) or (b and c)
●Comparaison :
a == b and c != d and e < f and g <= h and i > j and k >= l
(m in sequence) and (n not in sequence)
●Sur bits :
(a << 4) | (b & c >> 7)
●Déclaration :
●class NomClasse:
attributClasse = valeurDefaut;
# contructeur
def __init__(self, param1, ...):
self.attributObjet = param1
self.__attributPrive = valeur
def methode(self, param1, ...):
self.attributObjet += param1
# methode de conversion en chaine
def __str__(self):
return “attributClasse=%s, attributObjet=%s, attributPrive=%s”
%(self.attributClasse, self.attributObjet, self.__attributPrive)
●Utilisation :
instance = NomClasse(param1, ...)
instance.methode(param1, ...)
print instance
instance.attributObjet = valeur
NomClasse.attributClasse = valeur
print instance