Last active
May 19, 2016 04:28
-
-
Save zancas/96bee980680440b0f8ddfbc5cf9b667c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
class ReplaceDefaultNameMixin(object): | |
def __getattribute__(self, name): | |
if name in self._meta_data['override_classes']: | |
return self._meta_data['override_classes'][name](self) | |
elif name in self.__dict__: | |
return self.__dict__[name] | |
else: | |
return self.__getattr__(name) | |
.... | |
and you must add | |
self._meta_data['override_classes'] = {FOO.__name__: FOO} | |
to the class that's receiving the mixin... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment