Skip to content

Instantly share code, notes, and snippets.

@PaulSchweizer
Last active November 13, 2015 01:06
Show Gist options
  • Select an option

  • Save PaulSchweizer/485a4441ee7db86dac5f to your computer and use it in GitHub Desktop.

Select an option

Save PaulSchweizer/485a4441ee7db86dac5f to your computer and use it in GitHub Desktop.
Change class methods on __new__
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