Appliying method to list of objects
Remco Gerlich
scarblac at pino.selwerd.nl
Thu May 31 17:59:01 EDT 2001
eloy <eloy at rabinf50.uco.es> wrote in comp.lang.python:
> I couldn't find a cannonical (ti!mtowtdi) and efficient way to improve
> this:
>
> for i in list:
> i.dosomething()
>
> Perhaps
>
> map( lambda x: x.dosomething(), list )
>
> But the lambda screeches, somehow: I guess there must be a better way to
> do it.
>
> Using apply()?. But how?.
>
> I'm a bit new, so sorry if this is an easy one :).
Your first try (the for loop) is absolutely perfect.
--
Remco Gerlich
More information about the Python-list
mailing list