[Tutor] Tutor Digest, Vol 101, Issue 12

Osemeka Osuagwu abasiemeka at gmail.com
Thu Jul 5 00:49:26 CEST 2012


Hi Alan,
I appreciate the tip. Using the operator module does look better, the speed
is about the same too.

Thanks.
Abasiemeka

------------------------------
>
> Message: 3
> Date: Wed, 04 Jul 2012 18:13:36 +0100
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Bothersome NoneType Error for a List object
> Message-ID: <jt1tk0$fnd$1 at dough.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 04/07/12 17:01, Osemeka Osuagwu wrote:
>
> >      lcm = reduce(lambda x, y: x*y, templist)     #my first lambda
> > expression! (multiply all members of templist
>
> Congratulations :-)
>
> But you could have done:
>
> import operator
> lcm = reduce(operator.mul, templist)
>
> instead.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120704/dab0e47f/attachment.html>


More information about the Tutor mailing list