Class in class

Greg Ewing greg.ewing at compaq.com
Mon Sep 6 18:00:26 EDT 1999


Gurvijay Singh Bhatti wrote:
> 
> Dear everyone,
> 
> Like C++ and Java, is it possible to declare a class in a class? If it
> is then could you tell how?

class Foo:

  ...

  class Blarg:

    ...

The class Blarg is now a class attribute of class Foo,
so you can refer to it as Foo.Blarg, or as self.Blarg
within any method of class Foo.

Greg




More information about the Python-list mailing list