It may be too much, but one of the possible ways is to implement a wrapper over the output stream:
import pprint,sys,re class writer : def write(self, text): text=re.sub(r'u\'([^\']*)\'', r'\1',text) sys.stdout.write(text) wrt=writer() d = { u'foo': u'bar', u'baz': [u'apple', u'orange', u'pear', u'guava', u'banana'], u'hello': u'world'} pp = pprint.PrettyPrinter(stream=wrt) pp.pprint(d)
Output:
{baz: [apple, orange, pear, guava, banana], foo: bar, hello: world}
You can also put quotes inside parents to have single quotes around strings, e, g, 'foo': 'bar':
text=re.sub(r'u(\'[^\']*\')', r'\1',text)
This gives:
{'baz': ['apple', 'orange', 'pear', 'guava', 'banana'], 'foo': 'bar', 'hello': 'world'}