>>> You can do stuff like this: lambda x: x and 2 or 3
>>lambda x: {True:2,False:3}.get(bool(a))
And by the way, I just noticed that this kind of hack is essentially
"pushing the control (statement) inside expressions"... People should
really admit that statements are expressions and stop twis
On Fri, 10 Jun 2005 06:57:19 -0700, Kay Schluehr wrote:
>> You can do stuff like this: lambda x: x and 2 or 3
>lambda x: {True:2,False:3}.get(bool(a))
I also think these solutions are just hacks, less efficient, less
readable. One shouldn't have to twist her mind to write such an easy idea.
_
> For instance, if assignment were done in an expression, the targets would
> have to be quoted to avoid having them evaluated. Or the assignment
> expression would have to be a 'special expression' that did not evaluate
> all its terms (like setq in some (just older?) lisps). In Python, that
Well, thanks for the answers. I guess the fact is that python does not
want to be a functional programming language. This concept is quite large,
and since there is a proper notion of function with closure, I'd say
python is already quite a functional programming language. Even if
assignations and
Hi,
I tried python, and do like it. Easy to learn and read (at least for the
commonly used part), has a very large community so great doc and
contributions, and... the design is clean. I come from functional
programming languages, and I do like the proper static binding, the first
class functions