Created
April 13, 2019 15:48
-
-
Save isidentical/ef96bc3cc7bf95ec954ad145628a8063 to your computer and use it in GitHub Desktop.
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
class Parent: | |
items = [] | |
def __init_subclass__(cls): | |
cls.items = Parent.items.copy() | |
class Child(Parent): | |
pass | |
Parent.items.append(1) | |
Child.items.append(2) | |
assert Parent.items == [1] | |
assert Child.items == [2] | |
assert Child.items is not Parent.items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment