Skip to content
Advertisement

What’s the difference between an inner class and an inner inner class in python? [duplicate]

Shouldn’t field be undefined on line 50? It was my understanding that inner nested classes did not have visibility to outer classes, as I ran into on line 65… Just seems kind of inconsistent and I would love to have a better understanding of the outer nested classes visibility to avoid any confusion in the future.

JavaScript

https://gist.github.com/Krewn/073a8cf8ed32d0d78171d409d71c74f0?fbclid=IwAR1yb7jREw91wloquHVGEM_bd2whzxPaBJ8GxJR7CcdigLJGlkfmI2RVrg0

Advertisement

Answer

I’ve write very simplified example:

JavaScript

And class A is available as in inner as in inner inner class.

By initializing the levels after defining the game field rather than initializing the levels in the game field definition we are able to avoid the unresolved name error. See modified code.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement