0

EDIT:

I will add the whole code, the names of clases and stuff are in spanish but i hope you understand:

class Rubro():
'''
Representa un rubro de venta. Por ejemplo: pastas y quesos son dos
rubros diferentes.
'''
def __init__(self, id, nombre, descripcion, icono=None):
    self.id = id
    self.nombre = nombre
    self.descripcion = descripcion
    self.icono = icono
    self.col_variedades = {}
    self.objBroker = persistencia.obtener_broker(self, None)

def obtener_todos(self):
    self.objBroker.cargar_todo() 

class Broker():
def cargar_todo(self):
    pass


class sqliteBrokerArticulos(Broker):

def __init__(self):
    self.obj_db = sqliteDB()

def cargar_todo(self):
    return self.ejecutar("SELECT * FROM articulos")

def ejecutar(self, sentenciaSQL):
    conn = self.obj_db.abrir_conexion()
    try:
        conn.execute(sentenciaSQL)
        conn.commit()
    except:
        return False
    self.obj_db.cerrar_conexion()

I dont know how to explain it really, this is the code:

class A():

    def a(self):
        return self.objC.b()

class B():
    def b(self):
       #do something

class C(B):

    def b(self):
       #do something else

The problem is that it does not get into b(), It just skip it, and goes out of a() when it reachs that line

I dont know what could it be.

leojg
  • 1,156
  • 3
  • 16
  • 40
  • 1
    Please specify, how you're calling any method here. There are only class definitions so far. Besides that, you missed the `object` for the baseclasses in all classes. Maybe that's already your problem. – Michael Oct 05 '12 at 22:48
  • 4
    You probably simplified too much. Even with the necessary additions to just make the code valid, I still see no way how `b` could not be called. – Felix Kling Oct 05 '12 at 22:48
  • Another problem: you can't have an empty body after a `:`. You need at least `pass` to make this code runnable. – Keith Randall Oct 05 '12 at 22:50
  • Simplifying your code is good for SO questions, but it should run and show the problem at hand so we can understand the issue. – Gareth Latty Oct 05 '12 at 22:53
  • I edited the post with the actual code. Thanks for helping ^^ – leojg Oct 05 '12 at 23:03
  • Is your actually code indented as you copied it here? Indentation *is* part of the syntax in Python. You have to get it exactly right... – Pedro Romano Oct 05 '12 at 23:07

1 Answers1

0

Are you wondering why the B.b() method is never called? Or why the C.b() method is never called?

If the former, it's because in C.b(), you don't call the superclass method:

>>> class B(object):
...   def b(self):
...     print "in B.b"
...
>>> class C(B):
...   def b(self):
...     print "in C.b"
...
>>> c = C()
>>> c.b()
in C.b
>>> class C(B):
...   def b(self):
...     print "in C.b"
...     super(C, self).b()
...
>>> c = C()
>>> c.b()
in C.b
in B.b
>>>
Brenden Brown
  • 3,125
  • 1
  • 14
  • 15