Ilias Lazaridis wrote: > I have this python code > > class Car: > """Type of car.""" > > manufacturer = f.string() > model = f.string() > modelYear = f.integer() > > _key(manufacturer, model, modelYear) > > def __str__(self): > return '%s %s %s' % (self.modelYear, self.manufacturer, self.model)
What is f.string()? What is _key()? Are you using a metaclass here? Did you intentionally omit an __init__() method? If this is working code there is a lot you are not showing. > and would like to see it e.g. this way: > > class Car: > """Type of car.""" > > manufacturer = f.string(true, str=2) > model = f.string(true, str=3) > modelYear = f.integer(true, str=1) > > - > > how would the factory method look like? > > def string(self, key, str ) > # create somehow the __str__ function > # create somehow the key This would go in your metaclass __init__ I think. But hard to say without more details. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor