Python Online Compiler & Playground
HTML/CSS/JavaScript
HTML
CSS
Javascript
C++
C
PHP
Java
Python
Swift
C#
Ruby
Node.JS
Kotlin
jQuery
Go
R
TypeScript
Start Python Course
Register
pseudo private class variable
+6
Author: Tibor Santa
Dark
Public
Save
PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#pseudo-private class variable
class
b
:
__a =
'boo!'
#this does not work
#print(b.__a)
t = b
()
#this does not work
#print(t.__a)
#this works!
print
(
t._b__a
)
print
(
b.
__dict__
[
'_b__a'
])
Enter to Rename, Shift+Enter to Preview
OUTPUT