Skip to content

Instantly share code, notes, and snippets.

@rbpasker
Last active December 17, 2015 10:58
Show Gist options
  • Save rbpasker/5598612 to your computer and use it in GitHub Desktop.
Save rbpasker/5598612 to your computer and use it in GitHub Desktop.
class mybase:
derived_from = None
def set_derived_from(self, derived):
this.derived_from = derived
def derived(fn):
def wrapped(self, other):
att = fn(self, other)
if (att is not None) and (self.derived_From is not None):
att.derived_from = self.derived_from
return wrapped
class my(mybase):
@derived
def tag(self, d):
return self.md.add_name(data=d, info=Metadata.INFO['TAG'])
@rbpasker
Copy link
Author

otherwise I have to do this:

def tag(self, d):
    md = self.md.add_name(data=d, info=Metadata.INFO['TAG'])
    md.derived_from = self.derived_from
    return md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment