class Data:
def __init__(self, dia , mes, ano):
print("Construindo objeto ... {}".format(self))
self.dia = dia
self.mes = mes
self.ano = ano
def formatada(self):
print("{0}/{1}/{2}".format(self.dia, self.mes, self.ano))
Saida do console:
>>> from data import Data
>>> d = Data(21,11,2007)
Construindo objeto ... <data.Data object at 0x7f71b6be1580>
>>> d.formatada()
21/11/2007