[PEAK] generic function signature changes

Phillip J. Eby pje at telecommunity.com
Thu Jun 15 14:49:00 EDT 2006


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.




More information about the PEAK mailing list