在python中实现语言约束的模块
lang的Python项目详细描述
lang-python语言约束
===============
特性:
-access修饰符
-private&protected修饰符
-protect变量、属性、getter和setter
-class decorators、meta类、基类强制约束
-接口类(仅签名和类成员)
-抽象类、方法、属性
-最终类(&;方法wip)
示例:
----
**受保护/私有成员**
*私有变量只能由同一类访问,而受保护的变量也可以由子类访问。*
>类框(对象):
>类框(对象):
>类框(对象):
br/>类框(强制保护):
def\uu init\uu(self):
self.\u cant\u touch\u this=7
private与protected相同,但exchange“protected”与“private”。私有变量是以“\\”开头以“\\”结尾的变量,例如:“\\u i_am_private_for_this_class”
**protected/private properties**
>类框(对象):
@protected_property
def size(self):
…
@size.setter
def size(self,值:
…
仅受保护的setter/getter
类框(对象):
@仅受保护的setter
定义大小(自):
…
@size.setter
定义大小(自):
…
**接口类**
类IBox(interface):
或u metaclass_uuu=EnforceInterfaceMeta
默认高度=10
def大小(self):
pass
def calculate_u volume(self):
pass
如果实现了一个函数,它的源不只是“pass”,则抛出异常。
**抽象类**BR/>< BR/>这已经存在于Python(ABC模块)中,所以我只把它包在同一个包中。
BR/>类框(摘要):< By/>或Meta语言> = Meta
BR/> @ DEBR/> DEF IAM摘要(自):
BR/>大小(self):
…
**最终类**
>最终类是不能子类化的类
类最佳框(对象):
uu元类
installation
----
或克隆git repo并运行:
python setup.py install
许可证
——
此模块位于[apache 2.0]许可证下(http://www.apache.org/licenses/license-2.0)。
linkedin:amit assaraf
电子邮件:amit@helpi.me
===============
特性:
-access修饰符
-private&protected修饰符
-protect变量、属性、getter和setter
-class decorators、meta类、基类强制约束
-接口类(仅签名和类成员)
-抽象类、方法、属性
-最终类(&;方法wip)
示例:
----
**受保护/私有成员**
*私有变量只能由同一类访问,而受保护的变量也可以由子类访问。*
>类框(对象):
>类框(对象):
>类框(对象):
br/>类框(强制保护):
def\uu init\uu(self):
self.\u cant\u touch\u this=7
private与protected相同,但exchange“protected”与“private”。私有变量是以“\\”开头以“\\”结尾的变量,例如:“\\u i_am_private_for_this_class”
**protected/private properties**
>类框(对象):
@protected_property
def size(self):
…
@size.setter
def size(self,值:
…
仅受保护的setter/getter
类框(对象):
@仅受保护的setter
定义大小(自):
…
@size.setter
定义大小(自):
…
**接口类**
类IBox(interface):
或u metaclass_uuu=EnforceInterfaceMeta
默认高度=10
def大小(self):
pass
def calculate_u volume(self):
pass
如果实现了一个函数,它的源不只是“pass”,则抛出异常。
**抽象类**BR/>< BR/>这已经存在于Python(ABC模块)中,所以我只把它包在同一个包中。
BR/>类框(摘要):< By/>或Meta语言> = Meta
BR/> @ DEBR/> DEF IAM摘要(自):
BR/>大小(self):
…
**最终类**
>最终类是不能子类化的类
类最佳框(对象):
uu元类
installation
----
或克隆git repo并运行:
python setup.py install
许可证
——
此模块位于[apache 2.0]许可证下(http://www.apache.org/licenses/license-2.0)。
linkedin:amit assaraf
电子邮件:amit@helpi.me