llama.placeholder module

A module that allows you to construct placeholder objects for entities that can’t be imported. These placeholders don’t actually do anything and raise exceptions on use/instantiations, so their purpose is to allow a program to load and run as long as unavailable modules are not used. Also provides functions for seeing which placeholders have been created, allowing you to easily figure out which objects could not be imported and are instead just placeholders (useful if you are trying to get a software environment installed and want to know what functionality won’t work due to missing modules).

llama.placeholder.placeholderclass(name, modulename, bases=<class 'object'>)

Define and return a placeholder class that raises a NotImplementedError on instantiation.

  • name (str) – The name of the new class.
  • modulename (str) – The name of the module you would like to import from.
  • bases (tuple) – The base classes of the new placeholder class.

newclass – A placeholder class that immediately raises a NotImplementedError when you try to instantiate it.

Return type:


llama.placeholder.registerstub(name, modulename, stub)

Register a stub object. Just a way to keep track of when partial implementations of objects have been defined as replacements for modules that cannot be imported for whatever reason (since these stub objects might not provide perfect/full functionality of the missing modules).

  • name (str) – The variable name of the stub object.
  • modulename (str) – The name of the module where it is defined; you should probably set this to __name__ to get the name of the defining scope for the stub.
  • stub (function or type) – The stub object itself.