A superclass should never be aware of its subclasses. Or so I thought.
I have a Filter class, which wraps a function and some of its kwargs. Some other kwargs are callable eg
you can then use the Filter object like so
You specify the callable_kwargs when constructing the filter.
Filter can have 0 or more callable_kwargs. LabelFilter inherits from Filter, and has at least one callable_kwarg: label.
I want Filter&LabelFilter (the filter constructed from the binary & operation between filters) result to be LabelFilter since it has at least one callable kwarg which is label.
At the same time, I probably don't want the Filter class to be aware of its subclasses (from software engineering considerations).
What's the appropriate way to achieve that?
(if it matters at all,the actual programming language is python, so there are no friend functions).