# coding: latin-1 s = """class carre : def __init__( self, a) : self.a = a def __str__ (self) : return "carre " + str (self.a) class rectangle (carre): def __init__(self,a,b) : carre.__init__(self, a) self.b = b def __str__ (self) : return "rectangle " + str (self.a) + " x " + str (self.b)""" obj = compile(s,"","exec") # code à compiler exec (obj) # classes incorporées au programme r = rectangle (3,4) print r # affiche rectangle 3 x 4 c = carre (5) print c # affiche carre 5