group several methods under a attribute

jelle jelleferinga at
Mon Apr 6 21:52:50 CEST 2009

Hi Aaron,

Thanks a lot for your suggestions.
I wasnt familiar with the __get__ magic, which seems interesting.

So, finally it seems that the cleanest pattern is:

class ClsA( object ):
    def __init__( self, other ):
        self.inst= other

    def submethA( self, arg ):
        print( 'submethA %r, instance %r'% ( arg, self.inst ) )

class ClsB( object ):
    def methA( self, arg ):
        self.A= ClsA( self )
        print( 'methA %r'% arg )

b= ClsB( )
b.methA( 'this' )
b.A.submethA( 'that' )

Many thanks,


More information about the Python-list mailing list