Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import types
- class SelfDocumenting( object ):
- @classmethod
- def getMethods( aClass ):
- return [ (n,v.__doc__) for n,v in aClass.__dict__.items()
- if type(v) == types.FunctionType ]
- def help( self ):
- """Part of the self-documenting framework"""
- print self.getMethods()
- class SomeClass( SelfDocumenting ):
- attr= "Some class Value"
- def __init__( self ):
- """Create a new Instance"""
- self.instVar= "some instance value"
- def __str__( self ):
- """Display an instance"""
- return "%s %s" % ( self.attr, self.instVar )
- >>> ac= SomeClass()
- >>> ac.help()
- [('__str__', 'Display an instance'), ('__init__', 'Create a new Instance')]
Add Comment
Please, Sign In to add comment