[Python-3000] Minor hitch writing the Function Signature PEP

Bill Birch birchb at tpg.com.au
Sun Apr 23 14:11:29 CEST 2006


On 2006年4月23日 05:36 am, Talin wrote:
> @precondition( y=NotNegative )
> def power( x, y ):
>    ...
> ...where 'NotNegative' is a function which simply does an assert( value >= 
0 )
The phrase "y=NotNegative" is a classic type constraint predicate.
Given that type expressions will be dynamic (see GVD blog 
http://www.artima.com/weblogs/viewpost.jsp?thread=87182) 
how about:
def power(x, y : NotNegative):
 body...
or
def power(x, y : not Negative):
 body...
or even:
def power(x, y : (lambda t: t > 0) ):
 body...


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /