Declaring a class level nested class?

Lie Ryan lie.1296 at gmail.com
Thu Dec 3 10:07:27 EST 2009


On 12/3/2009 3:55 PM, cmckenzie wrote:
> I can't figure out what the correct way to construct the "nested"
> class so it can belong to "module".
>

which one you want?

1. The Outside's class contains a nested class
class Outside(object):
     class Inside(object):
         ...

2. The Outside's class contains an instance of the nested class
class Outside(object):
     class inside(object):
         ...
     inside = inside()

3. The Outside's instance contains an instance of the nested class
class Outside(object):
     class Inside(object):
         ...
     def __init__(self):
         self.inside = Outside.Inside()


4.



More information about the Python-list mailing list