We are currently porting a MATLAB project to Python and thinking about the structure of the classes as we do not want to port the structure from MATLAB to Python but rather ensure that we design in in the most Pythonic way possible.
We have identified a class X that has several methods and later on we want to add new methods that work on objects of type X. It would make sense to make these new methods part of X, but we don't want to redefine X every time. Also, some of those methods are experimental and we would like to avoid adding them and in a later version remove them again.
What would be the Pythonic way to deal with this? We thought about adding new static methods in other classes Y,Z that can take X as an argument.
question from:
https://stackoverflow.com/questions/65831801/python-define-method-of-class-outside-of-class 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…