Article of interest: Python pros/cons for the enterprise
Jeff Schwab
jeff at schwabcenter.com
Sat Feb 23 21:53:01 EST 2008
Paul Rubin wrote:
> "Terry Reedy" <tjreedy at udel.edu> writes:
>> | Yes, this seems to be the Python way: For each popular feature of some
>> | other language, create a less flexible Python feature that achieves the
>> | same effect in the most common cases (e.g. lambda to imitate function
>> | literals, or recursive assignment to allow x = y = z).
>>
>> This is a rather acute observation. Another example is generators versus
>> full coroutines (or continuations). Guido is content to capture 80% of the
>> practical use cases of a feature. He never intended Python to be a 100%
>> replace-everything language.
>
> I don't understand the lambda example due to not being sure what Jeff
> means by "function literals". But in other languages, lambda is the
> basic primitive, and "def" or equivalent is syntax sugar.
Sorry, I didn't know what else to call them except "lambdas." I meant
the bare code blocks you can use in Perl, or what Java tries to achieve
via anonymous inner classes. So to use the Perl example: If you want
to sort a list using some arbitrary snippet of code as the comparison
function, you can write:
sort { code to compare $a and $b } @elements
This isn't really "native" in C++ either:
http://www.boost.org/doc/html/lambda.html
What language do you have in mind, in which lambda is more basic than
named definitions? Are you coming from a functional language background?
More information about the Python-list
mailing list