Skip to content

Instantly share code, notes, and snippets.

@dangra
Created July 22, 2015 14:52
Show Gist options
  • Save dangra/501fbcb302e4bab90fa5 to your computer and use it in GitHub Desktop.
Save dangra/501fbcb302e4bab90fa5 to your computer and use it in GitHub Desktop.
class ReplacementClass(object):
@property
def selector(self):
return custom selector
def process_response(self, response):
cls = type(response)
newclass = type('newclass', (ReplacementClass, getmro(response.__class__), cls))
class NewClass(ReplacementClass, response.__class__):
pass
return response.replace(cls=NewClass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment