I am using classes and inheritance to make a clock on Python. I am trying to make a function advance() inside class Fecha which inherits Calendar and Clock. I try to call the attribute self.__hora, but I get "Attribute error: Fecha object has no attribute...". I will post only a part of the code because it is a little big:
class Reloj(object):
__segundo = Contador(0, 60)
__minuto = Contador(0, 60)
__hora = Contador(0, 24)
def __init__(self, s, minu, h):
self.__segundo.setCuenta(s)
self.__minuto.setCuenta(minu)
self.__hora.setCuenta(h)
def set(self, s, minu, h):
self.__segundo.setCuenta(s)
self.__minuto.setCuenta(minu)
self.__hora.setCuenta(h)
def tic(self):
self.__segundo.contar()
Class Reloj is a little bigger, but the rest are just display functions. This is the class Fecha:
class Fecha(Reloj, Calendario):
def __init__(self,d,m,a,s,minu,h):
Reloj.__init__(self,s,minu,h)
Calendario.__init__(self,d,m,a)
def avanzar(self):
hora_previa= self.__hora
Reloj.tic(self)
if self.__hora < hora_previa:
self.avanzar()
def __str__(self):
return Calendario.__str__(self) +","+ Reloj.__str__(self)