Assign values from list to list of instances
Peter Otten
__peter__ at web.de
Tue Nov 1 11:22:02 EDT 2011
Gnarlodious wrote:
> I want to assign a list of variables:
> locus=[-2, 21, -10, 2, 12, -11, 0, 3]
>
> updating a list of objects each value to its respective instance:
>
> for order in range(len(Orders)):
> Orders[order].locus=locus[order]
>
> This works, even though it reads like doggerel. Is there a more
> pythonesque way using map or comprehension?
for order, place in zip(Orders, locus):
order.locus = place
More information about the Python-list
mailing list