Skip to content

Commit 98832e7

Browse files
author
Sakis Kasampalis
committed
Merge branch 'pep8_bridge' of https://github.com/jcdenton/python-patterns into jcdenton-pep8_bridge
2 parents d42086f + d671429 commit 98832e7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎bridge.py‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22

33

44
# ConcreteImplementor 1/2
5-
classDrawingAPI1:
6-
defdrawCircle(self, x, y, radius):
5+
classDrawingAPI1(object):
6+
defdraw_circle(self, x, y, radius):
77
print('API1.circle at{}:{} radius{}'.format(x, y, radius))
88

99

1010
# ConcreteImplementor 2/2
11-
classDrawingAPI2:
12-
defdrawCircle(self, x, y, radius):
11+
classDrawingAPI2(object):
12+
defdraw_circle(self, x, y, radius):
1313
print('API2.circle at{}:{} radius{}'.format(x, y, radius))
1414

1515

1616
# Refined Abstraction
17-
classCircleShape:
18-
def__init__(self, x, y, radius, drawingAPI):
19-
self.__x=x
20-
self.__y=y
21-
self.__radius=radius
22-
self.__drawingAPI=drawingAPI
17+
classCircleShape(object):
18+
def__init__(self, x, y, radius, drawing_api):
19+
self._x=x
20+
self._y=y
21+
self._radius=radius
22+
self._drawing_api=drawing_api
2323

2424
# low-level i.e. Implementation specific
2525
defdraw(self):
26-
self.__drawingAPI.drawCircle(self.__x, self.__y, self.__radius)
26+
self._drawing_api.draw_circle(self._x, self._y, self._radius)
2727

2828
# high-level i.e. Abstraction specific
29-
defresizeByPercentage(self, pct):
30-
self.__radius*=pct
29+
defscale(self, pct):
30+
self._radius*=pct
3131

3232

3333
defmain():
@@ -37,9 +37,9 @@ def main():
3737
)
3838

3939
forshapeinshapes:
40-
shape.resizeByPercentage(2.5)
40+
shape.scale(2.5)
4141
shape.draw()
4242

4343

44-
if__name__=="__main__":
44+
if__name__=='__main__':
4545
main()

0 commit comments

Comments
(0)