Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

The self argument#

Sumit Rawal answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • self argument in python

  • The self argument#

    0

    One of the major differences between functions and methods in Python is the first argument in the method definition. Conventionally, this is named self. The user can use different names as well, but self is used by almost all the developers working in Python. We will also be using this convention for ease of understanding.

    This pseudo-variable provides a reference to the calling object, that is the object to which the method or property belongs to. If the user does not mention the self as the first argument, the first parameter will be treated for reference to the object.

    Note: The self argument only needs to be passed in the method definition and not when the method is called.

    Given below is an example of implementing methods in a class: 

    Popularity 1/10 Helpfulness 1/10 Language python
    Source: Grepper
    Tags: python self
    Link to this answer
    Share Copy Link
    Contributed on May 17 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.