tobgu/pyrsistent

pformat on pyrsistent objects

Open

#70 建立於 2015年10月29日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)Python (1,943 star) (141 fork)batch import
enhancementhelp wanted

描述

It'd be great if pprint and pformat worked "properly" on pyrsistent objects. That is, if the output of pformat(some_pmap) were comparable to pformat(some_dict).

That is, the following Python code...

from pyrsistent import pmap
from pprint import pprint

some_dict = {'foo': 'reverse the earth', 'bar': 'on a train to bristol', 'baz': 'some rather long line'}

print '## normal dict'
pprint(some_dict)
print

print '## pmap'
pprint(pmap(some_dict))

... produces this output ...

## normal dict
{'bar': 'on a train to bristol',
 'baz': 'some rather long line',
 'foo': 'reverse the earth'}

## pmap
pmap({'baz': 'some rather long line', 'foo': 'reverse the earth', 'bar': 'on a train to bristol'})

Whereas it should produce:

## normal dict
{'bar': 'on a train to bristol',
 'baz': 'some rather long line',
 'foo': 'reverse the earth'}

## pmap
pmap({
  'baz': 'some rather long line', 
  'foo': 'reverse the earth', 
  'bar': 'on a train to bristol'})

... or something similar

(Related to #69, but this is a request for enhancement, rather than a defect report. Fixing this would probably also fix #69)

貢獻者指南