speeze.pear...@gmail.com writes: > ... > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that behave just like the library's trees, but whose nodes > have some extra methods.
If you are happy, the library supports extensions of this type (as e.g. "lxml" and "PyXB" do). Otherwise, you can likely use a technique called "monkey patching". This is dynamically changing code at startup time. In your case, it could look like: from ... import Node def new_method(self, ...): ... Node.new_method = new_method >From that moment on, the "Node" class has a new method "new_method". -- https://mail.python.org/mailman/listinfo/python-list