Last active
May 22, 2020 17:00
-
-
Save anselmobd/bb4de96ba3164656b462010ab0c94643 to your computer and use it in GitHub Desktop.
Decorator - Only execute the method if any argument is not None
This file contains 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
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