Skip to content

Instantly share code, notes, and snippets.

@vesche
Created January 1, 2019 21:02
Show Gist options
  • Save vesche/4c9f9e0a7fd508dd29be202310196d55 to your computer and use it in GitHub Desktop.
Save vesche/4c9f9e0a7fd508dd29be202310196d55 to your computer and use it in GitHub Desktop.
Nested attributes
class A:
def __init__(self):
self.b = B()
@property
def f1(self):
return self.b
class B:
def __init__(self):
self.c = C()
@property
def f2(self):
return self.c
class C:
@property
def f3(self):
return ':D'
a = A()
print(a.f1.f2.f3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment