The authors even go as far as saysing, on page 228 (first paragraph) that map() used that way has a performance benefit and is faster than a for loop.
Cheers Bernard On 5/13/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > How bizarre. I'm astonished that Lutz/Ascher even show that as a means > of changing an attribute. As Danny said, it's definitely an abuse of > map, > and there is no advantage whatsoever, as far as I can see. In fact I > suspect that it's actually slower than an explicit loop (because of > the extra list building). > > > However I was looking into lambdas in hope to eliminate the need to > > define a function. > > And a loop also avoids the need for a function, and therefore for > a function call, which is another reason the map should be slower. > > Its completely weird that a text book should even suggest that map > be used for this! > > Alan G > Author of the Learn to Program web tutor > http://www.freenetpages.co.uk/hp/alan.gauld > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor