Why do you need explicitly have the “self” argument in a Python method?

前端 未结 10 1455
借酒劲吻你
借酒劲吻你 2020-11-22 11:53

When defining a method on a class in Python, it looks something like this:

class MyClass(object):
    def __init__(self, x, y):
        self.x = x
        se         


        
10条回答
  •  时光说笑
    2020-11-22 12:34

    There is also another very simple answer: according to the zen of python, "explicit is better than implicit".

提交回复
热议问题