Skip to content

Instantly share code, notes, and snippets.

@nkuln
Created October 20, 2011 18:00
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 nkuln/1301815 to your computer and use it in GitHub Desktop.
Save nkuln/1301815 to your computer and use it in GitHub Desktop.
Playing with Mixin which is basically a multiple inheritance. I was confused before on what the line 'cls = TestMixin' does ..
class TestMixin(object):
member1 = ['gant','from','mixin']
def mixin_method(self):
print 'member 1 from self: %s' % self.member1
cls = TestMixin
print 'member 1 from cls: %s' % cls.member1
class Cat(TestMixin):
member1 = 'meow meow'
def bark(self):
print 'I bark %s' % self.member1
if __name__ == '__main__':
a = Cat()
a.bark()
a.mixin_method()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment