Skip to content

Instantly share code, notes, and snippets.

@arpitbbhayani
Created February 7, 2020 06:29
Show Gist options
  • Save arpitbbhayani/aad9cc378566e2b12c7326dfd914d420 to your computer and use it in GitHub Desktop.
Save arpitbbhayani/aad9cc378566e2b12c7326dfd914d420 to your computer and use it in GitHub Desktop.
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