bearophile wrote:
> SiegeLord:
> 
>> Back when I was programming Python I found the array comprehension syntax 
>> unreadable, so I always used the map equivalent.
> 
> Python devs have introduced list comps only after asking about their 
> "ergonomicity" level to many people. And for most of those people code like 
> this:
> 
> result1 = [x * x + 5 for x in xrange(10)]
> result2 = {x: x * x for x in xrange(20)}
> 
> Allows the programmer to see code purpose better and create higher-level 
> mental chunks than code like:
> 
> result1 = map(lambda x: x * x + 5, xrange(10))
> result2 = {}
> for x in xrange(20):
>     result2[x] = x * x
> 
        Why didn't you write the second like this to keep it functional:
result2 = dict (map (lambda x: (x, x*x), xrange (20)))

                Jerome
-- 
mailto:jeber...@free.fr
http://jeberger.free.fr
Jabber: jeber...@jabber.fr

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to