How to return a class instance in member function of a class?
问题 I want to return a class instance in member function of a class, my code is: class MyClass(object): def __init__(self, *args, **kwargs): [snippet] def func(self, *args, **kwargs): [snippet] return class_instnace_of_MyClass if __name__ == '__main__': obj = MyClass(...) newobj = obj.func(...) # type(newobj) is MyClass I think I can call __init__() in func() , and return a new instance of MyClass, but I don't think it is a Pythonic way to do so. How should I do that? Thank you! 回答1: I feel like