As others have mentioned, the repetition isn't bad, but in some cases a namedtuple can be a great fit for this type of issue. This avoids using locals() or kwargs, which are usually a bad idea.
from collections import namedtuple
# declare a new object type with three properties; x y z
# the first arg of namedtuple takesis a typename
# the second arg is comma-separated or space-separated property names
XYZ = namedtuple("xyz""XYZ", "x, y, z")
# create an object of type XYZ. properties are in order
xyzabc = XYZ("one", "two", 3)
print xyzabc.x
print xyzabc.y
print xyzabc.z
I've found limited use for it, but you can inherit a namedtuple as with any other object (example continued):
class MySuperXYZ(XYZ):
""" I add a helper function which returns the original properties """
def properties(self):
return self.x, self.y, self.z
xyz2abc2 = MySuperXYZ(4, "five", "six")
print xyz2abc2.x
print xyz2abc2.y
print xyz2abc2.z
print xyz2abc2.properties()