Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. class Foo():
  2.     def __init__(self, a):
  3.         self.a = a
  4.    
  5.     def forward(self, x):
  6.         x = self.__apply(x)
  7.         return x * self.a
  8.    
  9.     def __apply(self, x):
  10.         x = x * 2
  11.         return x
  12.  
  13. class Bar(Foo):
  14.     def __apply(self, x):
  15.         x = x * (-2)
  16.         return x
  17.  
  18. clas = Bar(1)
  19. clas.forward(1)  # вернется 2, а я хочу -2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement