[Tutor] Class in a class

Luis N tegmine at gmail.com
Fri Feb 18 00:00:59 CET 2005


Does it make sense to do this:

In [2]: class AB:
   ...:     pass
   ...:
In [3]: a = AB()

In [4]: a
Out[4]: <__main__.AB instance at 0x8428bec>

In [5]: class BC:
   ...:     def __init__(self, foo):
   ...:         self.foo = foo

In [6]: b = BC(a)

In [7]: b.foo
Out[7]: <__main__.AB instance at 0x8428bec>


More information about the Tutor mailing list