Why we need add self when we define a python function?

  • 0

    IT seems not necessary? and we use this self in other python function as well

  • 1

    when we define a python function in a Class, the self is necessary. But self isn't a key in python,so you can change self to any name you want.
    So the first parameter means one instance that Class have created.
    Can u understand? If not, write to me (kizimi@qq.com)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.