Map with an extra parameter

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Sep 8 20:08:57 EDT 2006


This may be what you need:

class foo:
  def __init__(self, a, b):
     self.a = a
     self.b = b

vars = [1,2,3,4,5,6]
objects = [foo(a, 1) for a in vars]


Note that in Python the new is expressed wit the () at the end:

>   f = new foo()

Bye,
bearophile




More information about the Python-list mailing list