Inspect
  • get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects
  • class Vehicle(object):
        """ Vehicle class """
    
        count = 0; # class attribute
    
        def __init__(self, brand):
            self.__brand = brand
            Vehicle.count += 1
    
        @property
        def brand(self):
            return self.__brand
    
        @brand.setter
        def brand(self, b):
            self.__brand = b
    
        @brand.deleter
        def brand(self):
            del self.__brand
    
        def __str__(self):
            return "Brand: %s" % self.__brand
    
        def __getattr__(self, attr):
            return "~"
    
        def __del__(self):
            Vehicle.count -= 1
            print("Delete %s, %d vehicles left ..." % (self.__brand, Vehicle.count))
    
    def main():
        v1 = Vehicle("Lincoln")
    
        import inspect
        from pprint import pprint
    
        m = inspect.getmembers(v1, inspect.ismethod)
        pprint(m)
    
    if __name__ == '__main__':
        main()
    		
    Reference
  • Python STL Library