Framework for a beginner

lkcl luke luke.leighton at gmail.com
Thu Apr 19 08:12:21 EDT 2012


On Thu, Apr 19, 2012 at 12:20 PM, Alek Storm <alek.storm at gmail.com> wrote:
> On Wed, Apr 18, 2012 at 11:21 PM, lkcl <luke.leighton at gmail.com> wrote:
>>
>> On Apr 11, 9:11 pm, biofob... at gmail.com wrote:
>>
>> > I am new to python and only have read the Byte of Python ebook, but want
>> > to move to the web. I am tired of being a CMS tweaker and after I tried
>> > python, ruby and php, the python language makes more sense (if that makes
>> > any "sense" for the real programmers).
>>
>>  yeah, it does :)  python is... the best word i can describe it is:
>> it's beautiful.  it has an elegance of expression that is only marred
>> by the rather silly mistake of not taking map, filter and reduce into
>> the list object itself: l.map(str) for example would be intuitive,
>> compact and elegant.  instead, i have to look up how to use map each
>> and every damn time!  the reason for the mistake is historical: map,
>> filter and reduce were contributed by a lisp programmer.  that lisp
>> programmer, presumably, was used to everything being function(args...)
>> and it simply didn't occur to anyone to properly integrate map, filter
>> and reduce properly into the list objects that they work with.
>
>
> Why not use list comprehension syntax?

 because it's less characters to type, and thus less characters to
read.  i find that syntax incredibly klunky.  left to right you're
reading, "you declare something to be the case... and then oh whoops
actually it's not really the case because it's modified by a list
thing" - it breaks reading expectations.

 that's what i meant about beauty and elegance.  the "bang per buck"
ratio in python, results obtained for the number of characters used,
is higher, and that's something that i personally find to be a
priority over speed.

 you don't *have* to use lambdas with map and reduce, you just have to
use a function, where a lambda happens to be a nameless function.

 another example of the compactness of python is kicking around
somewhere, i wish i could remember where it is.  it compares scheme
with python and java.  scheme does this amazing programming "thing" in
a single operator, expressed in 3 characters.  python manages the same
thing in about 10, and java requires *six* lines!


> It gets you map and filter
> functionality for free, and is more readable than python's clunky version of
> lambdas. I believe they're faster than the for-loop equivalents, but I'm not
> sure about the actual map() and filter() functions (reduce() was removed
> from 3.0 for reasons I will never understand).

 likewise.

 /salutes



More information about the Python-list mailing list