具有新的或删除的约束/属性的类型

subtypes的Python项目详细描述


注释

更改日志

  • 2011-01-29 adrian ilarion ciobanu <cia@mud.ro>
    • initial release 0.1.1
    • pypi-related fixups
    • minor bugfixing, documentation updates, package restructuring 0.1.18
  • 2011-01-30 adrian ilarion ciobanu <cia@mud.ro>
    • improved weaktuple’s __iter__() method
    • 0.1.19 release

说明

子类型是具有新的或移除的约束/属性的python类型。

目前,该软件包包括以下子类型:

亚型。弱耦合

the weaktuple is a tuple with weakened immutability.

the main difference between the two is that the weaktuple’s immutability is only concerned with the size and the underlying type of each component.

in other words, tuple’s immutability property can be viewed as a set of three constraints C = (tupleSize, tupleComponentValue, tupleComponentType) (the third may be somehow implicit). The weaktuple’s set of constraints has only two components: C = (tupleSize,tupleComponentType), equivalent to “tuple has a product type” if you like.

the values of weaktuple’s component can be updated as long as the component’s type and tuple’s size constraints are verified.

applicability: storing the arguments to a function as a tuple for a later function call: while computing a set of conditions, the arguments may be needing updates. It’s easier, clearer and hopefully faster to do an inplace tuple member update:

>>> from subtypes.weaktuple import weaktuple
>>> def f(p1,p2,p3):
...     print "called with:(%r,%r,%r)"%(p1,p2,p3)
...
>>> o=weaktuple([1,'abc',[(1,2),(1,3),(2,3)]])
>>> o
(1, 'abc', [(1, 2), (1, 3),(2, 3)])
>>> f(*o)
called with:(1,'abc',[(1, 2),(1, 3), (2, 3)])
>>> if issubclass(weaktuple,tuple): o[1]='cba'
>>> f(*o)
called with:(1,'cba',[(1,2), (1,3), (2,3)])
>>>

see weaktuple module documentation for additional information

即将到来:
  • 弱工具

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
未处理java Google PubSub-resent消息   java CannotAcquireLockException+LockAcquisitionException   atlassian fisheye如何处理“C:\Program Files\Java\jre7\bin\server\JVM.dll”中缺少“服务器”JVM的问题   jboss 6.3 eap linux环境中ear部署中的java问题   java SQL顺序字符串主键   java ascii shift程序几乎适用于整个字符串   java中excel工作表中的一条记录插入多条记录所需的sql逻辑   java这个方法如何计算Rational(1)。hashCode()?1的分子或分母本身就是1   java为什么在循环中的数组中分配引用后会出现NullPointerException?   java Seam 2中内置工厂的优势是什么   远程运行Java项目的eclipse   标记化Java中的标记化源代码   java从大文件中读取前缀后的值   java使用EntityManager调用PostgreSQL过程   java阅读行每隔一行跳过一行