Defining a class within another class and calling a parent method

邮差的信 提交于 2019-12-05 20:50:00

Unfortunately, python doesn't seem to have a way to refer to the enclosing instance.

Instead, in your outer __init__ where you choose which inner class to use, and presumably instantiate it, you will need to pass the outer object's self as a parameter to the inner class instance.

Edit: Picking up the theme of a redesign - if you can simply call the DoIt method, then wait for its return, then you can call Finalize in the same place (the caller, that is), thus avoiding the need for the inner to call the outer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!