generate list of partially accumulated values
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Sep 16 08:53:30 EDT 2007
On Sun, 16 Sep 2007 10:21:59 +0000, cesco wrote:
> The list is composed of objects:
> l = [obj1, obj2, obj3, obj4]
> and I need to call a method (say method1) on each object as follow: l1 =
> [obj1.method1(obj2), obj2.method1(obj3), obj3.method1(obj4), obj4]
>
> Is there a clean way of doing this?
Yes, write a function that loops over the list doing what you want. Not
everything needs to be a one-liner.
--
Steven.
More information about the Python-list
mailing list