Source code for core.utils.name

# core/utils/name.py
#
#

""" utils package. """

__copyright__ = "Copyright 2015, B.H.J Thate"

## NAME

[docs]def typed(obj): return named(obj).split(".")[-1]
[docs]def named(obj): return name(obj).split()[-1][1:-2]
[docs]def name(obj): """ return name of an object (type). """ t = str(type(obj)) s = str(obj) if "function" in t: pre, post = s.split(" at ", 1) pre, post = pre.split() name = "<function '" + post + "'>" elif "module" in t: pre, post = s.split(" from ", 1) name = "<" + pre[1:] + ">" elif "class" in t: if "method" in t: pre, post = s.split(" of ", 1) name = "<method '" + pre.split()[-1] + "'>" else: pre, post = t.split("class ", 1) name = "<ding '" + post[:-1][1:-1] + "'>" elif "built-in" in t: name = "<" + t + ">" return name