Abstract and concrete syntax
Kay Schluehr
kay.schluehr at gmx.net
Sat Jun 11 00:27:11 EDT 2005
Terry Reedy wrote:
> > lambda x: {True:2,False:3}.get(bool(a))
>
> This is limited by the requirement that both branches be computable
> regardless of the value of the condition.
>
> > which is both beautiful and pythonic.
>
> Beauty is in the eye of the beholder. It seems that relative pythonicity
> sometimes is also ;-).
That's what is really regrettable! Otherwise a creation of a "lazy
dict" that creates the value part of an item on demand would have been
reasonable to solve both the computational issue you mentioned and the
performance issue George worried about ( you are both right except for
the little example above :)
Kay
More information about the Python-list
mailing list