From 597dfca483a2a01a9d7dfe0a479db4bb232509b3 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 24 Oct 2021 12:38:11 +0200 Subject: [PATCH] also show dtype if available --- inspector.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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()