Only pprint our struct when we detect a py REPL

dict_differ
Tyler Goodlet 2022-08-11 15:56:28 -04:00
parent db8a3dd1b7
commit b75683879a
1 changed files with 7 additions and 1 deletions

View File

@ -18,6 +18,7 @@
Built-in (extension) types.
"""
import sys
from typing import Optional
from pprint import pformat
@ -42,7 +43,12 @@ class Struct(
}
def __repr__(self):
return f'Struct({pformat(self.to_dict())})'
# only turn on pprint when we detect a python REPL
# at runtime B)
if hasattr(sys, 'ps1'):
return f'Struct({pformat(self.to_dict())})'
return super().__repr__()
def copy(
self,