I'm trying to implement simple svg style colored complex objects in tkinter and want to be able to inherit default values from other previously defined objects.
I want to something roughly similar to ... class shape(object): def __init__(self, **kwds): # set a bunch of general defaults here. self.__dict__.update(kwds) def draw(self, x=0, y=0, scale=1.0): # draw the object hello = shape(text='hello') redhello = hello(color='red') largeredhello = redhello(size=100) largeredhiya = largeredhello(text='Hiya!') largeredhiya.draw(c, 20, 50) I think this will need to require __new__ or some other way to do it. But I'm not use how to get this kind of behavior. Maybe the simplest way is to call a method. redhello = hello.makenew( color='red' ) But I want to be able to have all the objects access alike? Hmmm.. I think maybe if if don't ever access shape (or Shape) directly in my data structure, then __new__ would work? So my first default object should be an instance of shape with a __new__ method to create more? Ok, off to try it. But any comments will be welcome. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list