__init__ and arguments in Python

前端 未结 6 1338
我寻月下人不归
我寻月下人不归 2021-01-31 14:53

I want to understand arguments of the constructor __init__ in Python.

class Num:
    def __init__(self,num):
        self.n = num
    def getn(self)         


        
6条回答
  •  清酒与你
    2021-01-31 15:35

    The current object is explicitly passed to the method as the first parameter. self is the conventional name. You can call it anything you want but it is strongly advised that you stick with this convention to avoid confusion.

提交回复
热议问题