Guest User

Untitled

a guest
Jun 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import types
  2.  
  3. class SelfDocumenting( object ):
  4. @classmethod
  5. def getMethods( aClass ):
  6. return [ (n,v.__doc__) for n,v in aClass.__dict__.items()
  7. if type(v) == types.FunctionType ]
  8. def help( self ):
  9. """Part of the self-documenting framework"""
  10. print self.getMethods()
  11.  
  12. class SomeClass( SelfDocumenting ):
  13. attr= "Some class Value"
  14. def __init__( self ):
  15. """Create a new Instance"""
  16. self.instVar= "some instance value"
  17. def __str__( self ):
  18. """Display an instance"""
  19. return "%s %s" % ( self.attr, self.instVar )
  20.  
  21. >>> ac= SomeClass()
  22. >>> ac.help()
  23. [('__str__', 'Display an instance'), ('__init__', 'Create a new Instance')]
Add Comment
Please, Sign In to add comment