Declaring a class level nested class?

inhahe inhahe at gmail.com
Thu Dec 3 00:14:55 EST 2009


it seems to me like it should work just fine if you just take out the
second line where it just says nestedClass

On Wed, Dec 2, 2009 at 11:55 PM, cmckenzie <mckenzie.c at gmail.com> wrote:
> Hi.
>
> I'm new to Python, but I've managed to make some nice progress up to
> this point. After some code refactoring, I ran into a class design
> problem and I was wondering what the experts thought. It goes
> something like this:
>
> class module:
>   nestedClass
>
>   def __init__():
>      self.nestedClass = nested()
>      print self.nestedClass.nestedVar
>
>   class nested():
>      nestedVar = 1
>      def __init__(self):
>         print "Initialized..."
>
> I can't figure out what the correct way to construct the "nested"
> class so it can belong to "module".
>
> I want a class level construct of "nested" to belong to "module", but
> I keep getting nestedClass isn't defined.
>
> My example isn't great or 100% accurate, but I hope you get the idea.
>
> Thanks.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list