Provide custom type infomation : Class metaclass : Class PYTHON examples


PYTHON examples » Class » Class metaclass »

 

Provide custom type infomation


Provide custom type infomation

       
class MyMeta(type):
    def __str__(cls)
       return "Class name is '%s'"%cls.__name__

class MyClass:
    __metaclass__ = MyMeta

x = MyClass()

print type(x)


           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Class
» Class metaclass