Op 26-06-13 00:27, Mark Janssen schreef: >> The main problem is getting to the top/end of the call chain. Classic >> example is with __init__, but the same problem can also happen with >> other calls. Just a crazy theory, but would it be possible to >> construct a black-holing object that, for any given method name, >> returns a dummy function that ignores its args? (Other forms of >> attribute lookup aren't going to be a problem, I think, so this can be >> just methods/functions.) Then you just subclass from that all the >> time, instead of from object itself, and you should be able to safely >> call super's methods with whatever kwargs you haven't yourself >> processed. Would that work? >> >> Caveat: I have not done much with MI in Python, so my idea may be >> complete balderdash. > Here's how it *should* be made: the most superest, most badassed > object should take care of its children. New instances should > automatically call up the super chain (and not leave it up to the > subclasses), so that the parent classes can take care of the chil'en. > When something goes wrong the parent class has to look in and see > what's wrong. Could you explain why you think it should work this way? Maybe illustrate how this is supposed to work.
Let take a very simple example. We have a class that works with a stream (anything with a write method). class Streamer: def __init__(self, strm): ... Now we find that we very often use this class with a file, so we would like to make a subclass that takes a filename as parameter. This we would write somehow like the following class Filer(Streamer): def __init__(self, fn): fl = open(fn, "a+") super.__init__(fl) ... Can you explain how this example should be written en work as you view things? -- http://mail.python.org/mailman/listinfo/python-list