Skip to content

Instantly share code, notes, and snippets.

@mfalade
Created February 23, 2017 10:53
Show Gist options
  • Save mfalade/8f9a244df4b3c680c5a3701c6144e81a to your computer and use it in GitHub Desktop.
Save mfalade/8f9a244df4b3c680c5a3701c6144e81a to your computer and use it in GitHub Desktop.
A simple illustration of the class __getattr__ method
class Andela:
fellows = 'top .5 percent in Nigeria'
fellow_list = [1,2,3,4,5]
@staticmethod
def say_the_chant():
print "Andela Aww Yea!!!!"
class SecondClass:
def __init__(self):
print('asdfas')
self.andela = Andela()
def __getattr__(self, desired_attr):
return getattr(self.andela, desired_attr)
first_guy = SecondClass()
import pdb; pdb.set_trace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment