Created
July 10, 2012 09:52
-
-
Save dripolles/3082387 to your computer and use it in GitHub Desktop.
simple example of Python MRO and class attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: class A(object): | |
...: x = [1,2,3] | |
...: | |
In [2]: class B(A): pass | |
...: | |
In [3]: b = B() | |
In [4]: b.x.append(33) | |
In [5]: A.x | |
Out[5]: [1, 2, 3, 33] | |
In [6]: b.x = 'asdasd' | |
In [7]: A.x | |
Out[7]: [1, 2, 3, 33] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment