Declaring a class level nested class?

cmckenzie mckenzie.c at gmail.com
Wed Dec 2 23:55:06 EST 2009


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.



More information about the Python-list mailing list