Stephen Thorne wrote: > On 6 Jan 2005 13:33:42 -0800, Rittersporn > <[EMAIL PROTECTED]> wrote: > > @condition("number>0 and number<2","result>=0") > > def sqrt(number): > > import math > > return math.sqrt(number) > > > > @condition("list(seq) is not None","sum(seq)==result") > > def my_sum(seq): > > tmp=0 > > for element in seq: > > tmp+=element > > return tmp > > > > print sqrt(1.2) > > print my_sum([1,2,3]) > > I think it would be nicer to have the pre and post conditions > being compilable.
Me too. > @condition((list(seq) is not None for seq in args), (sum(seq)==result > for ((seq,), result) in (args, result)) > > or something silly like that. Ian Bicking was just talking about @require decorators: http://blog.ianbicking.org/already-under-our-noses.html @require(int, int) def gcd(a, b): ... If we made a "checker" module for such things in the stdlib, we could write most of that: from checker import * @args((list, itemsnotNone, )) @returns((any, )) def my_sum(seq): tmp=0 for element in seq: tmp+=element return tmp Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list