Instance of inherited nested class in outer class not allowed?

mrstephengross mrstevegross at gmail.com
Wed Feb 27 13:52:57 EST 2008


> class Foo:
>       foo = Foo()
>
> You have to live with that. Just do
> Outer.foo = Outer.Parent()
> after your class-statement to achieve the same result.

Hmmm. Well, I see why that works. It's too bad, though. If I want to
keep all executed code safely within a "if __name__ == '__main__'"
block, it ends up a bit ugly. Then again, I guess this is just an
aspect of python I'll have to get used to. Is there a specific reason
it works this way, by chance?

--Steve



More information about the Python-list mailing list