import time class Fecha: # Constructor primario: def __init__(self, aghnio, mes, dia): self.aghnio = aghnio self.mes = mes self.dia = dia # Constructor extra: @classmethod def fecha_actual(cls): fecha_local = time.localtime() return cls(fecha_local.tm_year, fecha_local.tm_mon, fecha_local.tm_mday) def __str__(self): return '{}-{}-{}'.format(self.aghnio, self.mes, self.dia) if __name__ == '__main__': fecha1 = Fecha(2019, 1, 8) fecha2 = Fecha.fecha_actual() print(fecha1) print(fecha2)