Created
February 7, 2020 06:29
-
-
Save arpitbbhayani/aad9cc378566e2b12c7326dfd914d420 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 __call__(self, *args, **kwargs): | |
"""Overriding the __call__ function which makes the | |
instance callable. | |
""" | |
# fetching the function to be invoked from the virtual namespace | |
# through the arguments. | |
fn = Namespace.get_instance().get(self.fn, *args) | |
if not fn: | |
raise Exception("no matching function found.") | |
# invoking the wrapped function and returning the value. | |
return fn(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment