Only pprint our struct when we detect a py REPL
							parent
							
								
									db8a3dd1b7
								
							
						
					
					
						commit
						b75683879a
					
				|  | @ -18,6 +18,7 @@ | ||||||
| Built-in (extension) types. | Built-in (extension) types. | ||||||
| 
 | 
 | ||||||
| """ | """ | ||||||
|  | import sys | ||||||
| from typing import Optional | from typing import Optional | ||||||
| from pprint import pformat | from pprint import pformat | ||||||
| 
 | 
 | ||||||
|  | @ -42,8 +43,13 @@ class Struct( | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|  |         # 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 f'Struct({pformat(self.to_dict())})' | ||||||
| 
 | 
 | ||||||
|  |         return super().__repr__() | ||||||
|  | 
 | ||||||
|     def copy( |     def copy( | ||||||
|         self, |         self, | ||||||
|         update: Optional[dict] = None, |         update: Optional[dict] = None, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue