Advertisement
user_137

Untitled

Aug 25th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. >>> class A():
  2. ...     x = 5
  3. ...     def __init__(self):
  4. ...         self.y = 7
  5. ...
  6. ... class C(A):
  7. ...     cx = 15
  8. ...     def __init__(self):
  9. ...         self.cy = 17
  10. ...
  11. ... cc = C()
  12.  
  13. >>> cc.cy
  14. 17
  15.  
  16. >>> cc.y
  17. Traceback (most recent call last):
  18.   File "<stdin>", line 1, in <module>
  19. AttributeError: 'C' object has no attribute 'y'
  20. 'C' object has no attribute 'y'
  21.  
  22. >>> cc.cx
  23. 15
  24.  
  25. >>> cc.x
  26. 5
  27.  
  28. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement