python类装饰器用法实例,python实例
python类装饰器用法实例,python实例
本文实例讲述了python类装饰器用法。分享给大家供大家参考。具体如下:
#!coding=utf-8 registry = {} def register(cls): registry[cls.__clsid__] = cls return cls @register class Foo(object): __clsid__ = '123-456' def bar(self): pass print registry
运行结果如下:
{'123-456': <class '__main__.Foo'>}
希望本文所述对大家的Python程序设计有所帮助。
相关内容
- Python中函数的参数定义和可变参数用法实例分析,pyt
- python函数装饰器用法实例详解,python函数实例详解
- python生成器generator用法实例分析,pythongenerator
- python中字符串前面加r的作用,python字符串作用
- python避免死锁方法实例分析,python避免实例分析
- python定时器(Timer)用法简单实例,pythontimer
- Python实现处理管道的方法,python实现管道
- python中管道用法入门实例,python管道
- python基于multiprocessing的多进程创建方法,python多进程
- python抽象基类用法实例分析,python抽象实例分析
评论关闭