lambdak: multi-line lambda implementation in native Python

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jan 18 03:45:04 CET 2015


Roy Smith wrote:

> In article <54ba5a25$0$12991$c3e8da3$5496439d at news.astraweb.com>,
>  Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> 
>> Whitespace is significant in nearly all programming languages, and so it
>> should be. Whitespace separates tokens, and lines, and is a natural way
>> of writing (at least for people using Western languages).
> 
>>>> """x""" == " " "x" " "
> False

I'm not sure what you are trying to say there. The left hand side is the
string "x", the right hand side is the string " x ". I can tell you why
they're different, I just can't tell you the definitive component in the
Python interpreter which causes that difference (parser, lexer, keyhole
optimizer, compiler...). I suspect the answer is implementation-dependent.

""" is not the same as " " ", just as 123 and 1 2 3 are not the same.



>> *Indentation* is significant to Python, while most languages enable
>> tedious and never-ending style wars over the correct placement of braces
>> vis a vis indentation, because their language is too simple-minded to
>> infer block structure from indentation. Python does derive block
>> structure from indentation, as god intended (otherwise he wouldn't have
>> put tab keys on typewriters) and so Python doesn't suffer from the
>> interminable arguments about formatting that most other languages do.
> 
> Well, we do get to argue about
> 
> x = [1,
>      2,
>      3]
> 
> vs.
> 
> x = [1,
>      2,
>      3,
>     ]
> 
> vs. a few other variations based on how you group the first element with
> the opening bracket, or the last element with the closing bracket, and,
> of course, whether you use the last trailing comma or not.

True, but nowhere near the Holy Wars about the One True Brace Style in
languages like C.




-- 
Steven




More information about the Python-list mailing list