The exec statement compiles and executes a python statement.
#!/usr/bin/env python from PyTango import * devices = { 'mot1' : "p09/motor/exp.01"} for l in list( devices.keys()): exec "%s = DeviceProxy( '%s')" % (l, devices[l])
Another example:
for elm in dir(self): exec "temp = type(self.%s)" % elm print( "%s %s " % ( repr(elm), temp))