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

Accessing private attributes in the main code#

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

Contents


More Related Answers

  • Class access modifiers. public private protected what is it. Access Specifiers
  • c# get private property
  • what is public private and protected as together called
  • c# get private property
  • private access modifiers
  • Public properties can be created via Instance public fields
  • Does Java allow us to use private and protected modifiers for variables in interfaces?
  • 4. Separate Public, Protected and Private Attributes
  • Private attributes#
  • Private methods#
  • Private and Public Fields#

  • Accessing private attributes in the main code#

    0

    As discussed above, it is not common to have private variables in Python.

    Properties and methods with the __ prefix are usually present to make sure that the user does not carelessly access them. Python allows for free hand to the user to avoid any future complications in the code. If the user believes it is absolutely necessary to access a private property or a method, they can access it using the _ prefix for the property or method. An example of this is shown below:

    Popularity 1/10 Helpfulness 1/10 Language python
    Source: Grepper
    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.