Skip to content

Instantly share code, notes, and snippets.

@anselmobd
Last active May 22, 2020 17:00
Show Gist options
  • Save anselmobd/bb4de96ba3164656b462010ab0c94643 to your computer and use it in GitHub Desktop.
Save anselmobd/bb4de96ba3164656b462010ab0c94643 to your computer and use it in GitHub Desktop.
Decorator - Only execute the method if any argument is not None
def method_idle_on_none(old_method):
'''
Decorator: Only execute the method if any argument is not None
'''
def new_method(self, *args):
for arg in args:
if arg is not None:
old_method(self, *args)
break
return new_method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment