b3j0f.utils.reflect module

Python reflection tools.

b3j0f.utils.reflect.isoldstyle(cls)[source]

Return True if cls is an old style class (does not inherits from object in python2.

b3j0f.utils.reflect.base_elts(elt, cls=None, depth=None)[source]

Get bases elements of the input elt.

  • If elt is an instance, get class and all base classes.
  • If elt is a method, get all base methods.
  • If elt is a class, get all base classes.
  • In other case, get an empty list.
Parameters:
  • elt – supposed inherited elt.
  • cls (type or list) – cls from where find attributes equal to elt. If None, it is found as much as possible. Required in python3 for function classes.
  • depth (int) – search depth. If None (default), depth is maximal.
Returns:

elt bases elements. if elt has not base elements, result is empty.

Return type:

list

b3j0f.utils.reflect.find_embedding(elt, embedding=None)[source]

Try to get elt embedding elements.

Parameters:embedding – embedding element. Must have a module.
Returns:a list of [module [,class]*] embedding elements which define elt.
Return type:list
b3j0f.utils.reflect.is_inherited(elt, cls=None)[source]

True iif elt is inherited in a base class.

Parameters:
  • elt – elt to check such as an inherited element.
  • cls (type) – base cls where find the base elt.
Returns:

true if elt is an inherited element.

Return type:

bool