Add misc.object_builtin_name()

object_builtin_name() is meant to derive an object name from its
class name. Doesn't work well, but adding the code nonetheless for
improving it later.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-10-24 18:45:05 +02:00
commit ddfb500fa2

View file

@ -37,4 +37,13 @@ def atomic_store(contents, path): # export
os.rename(name, path)
_tmpfiles.remove(name)
# see https://stackoverflow.com/questions/2020014
def object_builtin_name(o, full=True): # export
#if not full:
# return o.__class__.__name__
module = o.__class__.__module__
if module is None or module == str.__class__.__module__:
return o.__class__.__name__ # Avoid reporting __builtin__
return module + '.' + o.__class__.__name__
atexit.register(_cleanup)