Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Advanced inner classes for Python

Project description

This module add some useful features to Python inner classes :

 class MyOuter:
    class MyInner:
       def hello(self):

outer attribute

The inner class gain an 'outer' attribute that reference its outer class.

  >>> MyOuter.MyInner.outer 
  <class '__main__.MyOuter'>

inner derivation

When the outer class is derived, the inner class is also derived in order to point at the derived outer class.

 class MyChildOuter(MyOuter):

 >>> MyChildOuter.MyInner.outer
 <class '__main__.MyChildOuter'>

carried inheritance

When the inner class is redefined in an outer subclass, it will automatically derivate from the inner class of the outer superclass.

  class MyChildOuter(MyOuter):
     class MyInner:

  >>> MyChildOuter.MyInner().hello()

inner instantiation

the outer attribute of an inner instance store it's outer instance

  outer = MyOuter()
  >>> outer
  <__main__.MyOuter object at 0x03BAA990>
  >>> outer.MyInner().outer
  <__main__.MyOuter object at 0x03BAA990>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for inner-class, version 0.2
Filename, size File type Python version Upload date Hashes
Filename, size inner-class-0.2.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page