Better results printing

This commit is contained in:
MikeTheWatchGuy 2018-08-10 17:38:31 -04:00
parent 5abcd7c546
commit d6ff296d9f
1 changed files with 11 additions and 1 deletions

View File

@ -1156,7 +1156,17 @@ class ListDict(OrderedDict):
return super().__getitem__(item)
def __str__(self):
return str(self.ToList())
listlike = True
for i, key in enumerate(self.keys()):
if i != key:
listlike = False
if listlike:
return str(list(self.values()))
else:
output = [("'" + k + "'" if isinstance(k, str) else str(k)) + ': ' + (
"'" + v + "'" if isinstance(v, str) else str(v)) for k, v in self.items()]
return '{' + ', '.join(output) + '}'
def ToList(self):
output = []