Jay Taylor's notes

back to listing index

python - What is the meaning of single and double underscore before an object name? - Stack Overflow

[web search]
Original source (stackoverflow.com)
Tags: python underscores stackoverflow.com
Clipped on: 2023-11-01

  • but how about if "__a" was a class variable, then you cannot access it even with the instructions from python docs.. Jul 6, 2017 at 7:07
  • Please can you update your answer with an example of double underscore with respect to inheritence?
    – variable
    Sep 9, 2019 at 15:56
  • 1
    ._variable, according to the posts above and PEP-8, is not only a convention: "from M import * does not import objects whose names start with an underscore.". However, in the presented case showing it as a class attribute, it doesn't change anything.
    – pdaawr
    May 3, 2021 at 9:07 Image (Asset 3/45) alt=
Add a comment
20
Image (Asset 5/45) alt=
Tim D
Add a comment
17
Image (Asset 7/45) alt=
3 revs
Mathieu Rollet
Add a comment
8
Image (Asset 8/45) alt=
Dev Maha
Add a comment
8
Image (Asset 9/45) alt=
grepit
Add a comment
7
Image (Asset 10/45) alt=
Marc
Add a comment
6
Image (Asset 11/45) alt=
u0b34a0f6ae
Add a comment
3
Image (Asset 12/45) alt=
aptro
Add a comment
2
Image (Asset 13/45) alt=
2 revs
Invader
Add a comment
0
Image (Asset 14/45) alt=
Timothy C. Quinn
Add a comment
0
Image (Asset 15/45) alt=
Karim Baidar
Add a comment
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

Visit chat

Linked

151
Underscore vs Double underscore with variables and methods
69
Private Variables and Methods in Python
38
Difference between "__method__" and "method"
55
What is the difference in python attributes with underscore in front and back
13
When to use one or two underscore in Python
12
Double underscore in python
4
Should I start a helper function with underscore(s)?
8
what does the double underscore __ mean in python?
5
Is there a name for double underscore functions?
2
Declaring private variable in Python
See more linked questions

Related

5
What does underscoring methods connote?
16
In Python, what is the underscore in front of the instance variable?
8
What does the underscore represent in Python?
0
A full list of special double-underscore properties in standard python libraries?
1
Python double leading and trailing underscore usage for class attributes
0
What does the Python naming convention with single/double underscore before a function mean?
40
Underscore after a variable name in Python
12
Double underscore in python
3
When does the name mangling occur when using double underscores?
4
What is the meaning of simply __ double underscore as a variable name? Just __ not follow another chars

Hot Network Questions

Question feed
Stack Overflow
Products
Company
Stack Exchange Network

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2023.10.31.43699