Mandus schrieb:

> As someone who like to do functional style programming, but without a
> lot of training in that dept., I miss what you ask for from time to
> time.
>
> I don't want to go to much into this discussion, just comment on a tiny
> little bit:
>
> Thu, 09 Jun 2005 03:32:12 +0200 skrev David Baelde:
> [snip]
> >
> > set_callback(obj,
> >              lambda x: (if a:
> >                2
> >              else:
> >                3)
> >
> [snip]
>
> You can do stuff like this: lambda x: x and 2 or 3

You can also do this

   lambda x: {True:2,False:3}.get(bool(a))

which is both beautiful and pythonic.

Kay

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to