[Python-ideas] where statement in Pyret
Nick Coghlan
ncoghlan at gmail.com
Sun Nov 10 15:48:07 CET 2013
On 10 November 2013 19:55, Tarek Ziadé <tarek at ziade.org> wrote:
> From the documentation example:
>
> fun sum(l):
> cases(List) l:
> | empty => 0
> | link(first, rest) => first + sum(rest)
> end
> where:
> sum([]) is 0
> sum([1, 2, 3]) is 6
> end
It would make more sense to just bake py.test style rich assertions
into the language in some way and let people write:
def sum(iterable):
# implementation of sum
assert sum([]) == 0
assert sum([1, 2, 3]) == 6
A mechanism to say "always execute assert statements in this module
regardless of optimisation level" could also be useful.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list