class Animation: #définition d'une classe 'Animation' """ Ma documentation """ def __init__(self, x=0, y=0): #Définition des variables d'instance self.point_x=x self.point_y=y def __str__(self): return "(%.2f %.2f)" %(self.point_x, self.point_y) def __repr__(self): return "Point(%.2f %.2f)" %(self.point_x,self.point_y) anim=Animation(3, 6) print str(anim) #(3.00 6.00) print repr(anim) #Point(3.00 6.00) |
Livres Sur ce Sujet
Apprendre à programmer avec Python 3 Apprenez à programmer en Python Python : Petit guide à l’usage du développeur agile Apprendre à programmer avec Python 3 : Avec plus de 50 pages de corigés d’exercices !