Last active
November 13, 2015 01:06
-
-
Save PaulSchweizer/485a4441ee7db86dac5f to your computer and use it in GitHub Desktop.
Change class methods on __new__
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
| class MyClass(object): | |
| """""" | |
| def __new__(cls, *args, **kwargs): | |
| """@todo documentation for __new__ | |
| @param cls The class to create | |
| """ | |
| created_class = super(MyClass, cls).__new__(cls, *args, **kwargs) | |
| def test(*args, **kwargs): | |
| """@todo documentation for test""" | |
| print 'New function!' | |
| # end def test | |
| setattr(created_class, 'test', test) | |
| return created_class | |
| # end def __new__ | |
| # end class MyClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment