Skip to content

Commit 2e7d0f2

Browse files
committed
Updating the underscore in Python names article
1 parent 04972c3 commit 2e7d0f2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

python-double-underscore/csv_data.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# csv_data.py
2-
31
import csv
42

53

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class A:
2+
def __init__(self):
3+
self.__attr = 0
4+
5+
def __method(self):
6+
print("A.__attr = ", self.__attr)
7+
8+
9+
class B(A):
10+
def __init__(self):
11+
super().__init__()
12+
self.__attr = 1 # Doesn't override A.__attr
13+
14+
def __method(self): # Doesn't override A.__method()
15+
print("B.__attr = ", self.__attr)

0 commit comments

Comments
 (0)