Skip to content

Instantly share code, notes, and snippets.

@HarkonenBade
Created February 23, 2018 14:41
Show Gist options
  • Save HarkonenBade/27cf6a8080eef556a108f51493781504 to your computer and use it in GitHub Desktop.
Save HarkonenBade/27cf6a8080eef556a108f51493781504 to your computer and use it in GitHub Desktop.
class Foo:
@classmethod
def my_list(cls):
if hasattr(cls, 'mylist'):
return cls.mylist
cls.mylist = []
return cls.mylist
class Bar(Foo):
pass
class Baz(Foo):
pass
a = Bar()
a.my_list().append(1)
b = Baz()
print(b.my_list())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment