[PEAK] generic function signature changes
Simon Belak
simon.belak at hruska.si
Thu Jun 15 14:56:13 EDT 2006
Phillip J. Eby wrote:
> At 08:41 PM 6/15/2006 +0200, Simon Belak wrote:
>> from dispatch import generic
>>
>> @generic()
>> def foo(bar):
>> pass
>>
>> @foo.when("bar > 2")
>> def foo_gt_2(bar):
>> return "bar > 2"
>>
>> @foo.when("bar == 2")
>> def foo_gt_2(bar, baz=24):
>> return baz
>
> The function's overall signature is determined by the @generic, so baz
> in your example will never be anything but 24, unless you call that
> method directly.
I misunderstood the question, thinking Kevin is asking how rigourously
specific methods need to follow the abstract declaration.
Cheers,
Simon
More information about the PEAK
mailing list