attr/attrs模块

attr简介

开源库,提供了为函数或类提供更直接的建立属性的方法。python

Github or PyPigit

用法

from attr import attrs, attrib


@attrs
class Foo:
    a = attrib(default=0)
    b = attrib(default='Hello world')

attrs简介

与attr模块相似,是最近比较流行的一款开源库,不影响线程和协程。attrs.orggithub

用法

import attr


@attr.s
class Foo:
    x = attr.ib()
    y = attr.ib()
相关文章
相关标签/搜索