mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
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:
parent
1f122fae82
commit
ddfb500fa2
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue