diff --git a/inspector.py b/inspector.py index c549ccd..4c6e970 100644 --- a/inspector.py +++ b/inspector.py @@ -79,7 +79,7 @@ class VariableInspector(object, metaclass=Singleton): def format_line(k, v): - return LINE.format(k, typename(v), size(v), format_value(v)) + return LINE.format(k, format_type(v), size(v), format_value(v)) def sorted_naturally(iterable, reverse=False): natural = lambda item: [int(c) if c.isdigit() else c.casefold() for c in RE_DIGITS.split(str(item))] @@ -112,6 +112,15 @@ def format_value(obj): #TODO: make magic numbers configurable res = res[:50] + " ... " + res[-50:] return res +def format_type(obj): + tn = typename(obj) + try: + dtype = obj.dtype + except AttributeError: + return tn + else: + return f"{dtype} {tn}" + inspector = VariableInspector()