Skip to content

Instantly share code, notes, and snippets.

@marskar
Last active September 27, 2018 04:01
Show Gist options
  • Save marskar/28100f5cd3e0f4b56fc2c839627b4df3 to your computer and use it in GitHub Desktop.
Save marskar/28100f5cd3e0f4b56fc2c839627b4df3 to your computer and use it in GitHub Desktop.
from importlib import import_module
def pydy(cls, src: str = 'helper'):
class Pydy(cls):
pass
mod = import_module(src)
internals = mod.__dict__.items()
method_names = [name for name, val in internals if callable(val)]
for name in method_names:
met = getattr(mod, name)
setattr(Pydy, name, met)
return Pydy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment