failing to instantiate an inner class because of its order

Pyenos pyenos at pyenos.org
Wed Dec 27 18:32:21 EST 2006


Pyenos <pyenos at pyenos.org> writes:

> class Model:
>         Controller() #problem
> 
> class View:
>         Model()
> 
> class Controller:pass
> 
> 
> Python interpreter complains that 'Name Error: Controller()' not defined.
>         

Following Edward Kozlowski's advice I can suggest to myself a solution:

class Model:pass

class View:
        Model() #this part is fine

class Controller:
        def __init__(self):
                self.Model=Model()

Controller.Model.Controller() #solution





More information about the Python-list mailing list