You would use setattr to bind a name that you don't know:
for pin in self.pin: setattr(self,pin.Name,pin.Value) However, I'm not sure why you're using a dictionary in this way. I don't totally understand the context, so I may be wrong, but I would code it more like this: class Power_Supply(device): pins = {'GND':(_DIG_OUT,_par2),'VCC':(_DIG_OUT,_par33)} def __init__(self): for pin in pins.items(): #pin will be key,value setattr(self,pin[0],pin[1]) or even: class Power_Supply(device): pins = {'GND':(_DIG_OUT,_par2),'VCC':(_DIG_OUT,_par33)} def __init__(self): self.__dict__.update(pins) #self.__dict__ is the name mapping for any object, update will insert any new values from a new dictionary into the old one
-- http://mail.python.org/mailman/listinfo/python-list