Skip to content

Instantly share code, notes, and snippets.

@isidentical
Created April 13, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidentical/ef96bc3cc7bf95ec954ad145628a8063 to your computer and use it in GitHub Desktop.
Save isidentical/ef96bc3cc7bf95ec954ad145628a8063 to your computer and use it in GitHub Desktop.
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