fork download
  1. from pprint import PrettyPrinter
  2.  
  3. class MyPrettyPrinter(PrettyPrinter):
  4. def __init__(self, *args, **kwargs):
  5. PrettyPrinter.__init__(self, *args, **kwargs)
  6. def format(self, object, context, maxlevels, level):
  7. (repr, readable, recursive) = PrettyPrinter.format(self, object, context, maxlevels, level)
  8. return (type(repr)(object), readable, recursive) if isinstance(object, str) else (repr, readable, recursive)
  9.  
  10. print(MyPrettyPrinter().pformat(['x']))
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
[x]