L
Lorenzo Di Gregorio
Hi,
I'm wondering what would be the preferred way to solve the following
forward reference problem:
---------------------------------------
class BaseA(object):
def __init__(self):
return
class DebugA(BaseA):
def __init__(self):
return
# here I would have a prototype of class A which is the same as class
BaseA
class B(object):
def __init__(self):
self.obj = A()
return
if __name__ == "__main__":
# class A(BaseA): # Uncomment this for using BaseA objects
# pass
class A(DebugA): # Uncomment this for using DebugA objects
pass
---------------------------------------
I can figure out some ways to fix this but none seems satisfying.
Either they are too specific or too cumbersome.
A runtime redefinition of class A does not seem to work either.
What would be the most "pythonesque" solution other than sorting out
the class order?
Best Regards,
Lorenzo
I'm wondering what would be the preferred way to solve the following
forward reference problem:
---------------------------------------
class BaseA(object):
def __init__(self):
return
class DebugA(BaseA):
def __init__(self):
return
# here I would have a prototype of class A which is the same as class
BaseA
class B(object):
def __init__(self):
self.obj = A()
return
if __name__ == "__main__":
# class A(BaseA): # Uncomment this for using BaseA objects
# pass
class A(DebugA): # Uncomment this for using DebugA objects
pass
---------------------------------------
I can figure out some ways to fix this but none seems satisfying.
Either they are too specific or too cumbersome.
A runtime redefinition of class A does not seem to work either.
What would be the most "pythonesque" solution other than sorting out
the class order?
Best Regards,
Lorenzo