This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,48 @@
Python 3.2.3 (default, May 3 2012, 15:54:42)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> help('pprint.pprint')
Help on function pprint in pprint:
pprint.pprint = pprint(object, stream=None, indent=1, width=80, depth=None)
Pretty-print a Python object to a stream [default is sys.stdout].
>>> from pprint import pprint
>>> for tree in [ (1, 2, 3, 4, 5, 6, 7, 8),
(1, (( 2, 3 ), (4, (5, ((6, 7), 8))))),
((((1, 2), 3), 4), 5, 6, 7, 8) ]:
print("\nTree %r can be pprint'd as:" % (tree, ))
pprint(tree, indent=1, width=1)
Tree (1, 2, 3, 4, 5, 6, 7, 8) can be pprint'd as:
(1,
2,
3,
4,
5,
6,
7,
8)
Tree (1, ((2, 3), (4, (5, ((6, 7), 8))))) can be pprint'd as:
(1,
((2,
3),
(4,
(5,
((6,
7),
8)))))
Tree ((((1, 2), 3), 4), 5, 6, 7, 8) can be pprint'd as:
((((1,
2),
3),
4),
5,
6,
7,
8)
>>>

View file

@ -0,0 +1,51 @@
>>> tree = "a",("b0",("c1","c2",("d",("ef","gh")),"c3",("i1","i2","i3",("jj"),"i4",("kk","m"))),"b1",("C1","C2",("D1",("E"),"D2","D3"),"C3"))
>>> pprint(tree, width=1)
('a',
('b0',
('c1',
'c2',
('d',
('ef',
'gh')),
'c3',
('i1',
'i2',
'i3',
'jj',
'i4',
('kk',
'm'))),
'b1',
('C1',
'C2',
('D1',
'E',
'D2',
'D3'),
'C3')))
>>> copypasteoutput = ('a',
... ('b0',
... ('c1',
... 'c2',
... ('d',
... ('ef',
... 'gh')),
... 'c3',
... ('i1',
... 'i2',
... 'i3',
... 'jj',
... 'i4',
... ('kk',
... 'm'))),
... 'b1',
... ('C1',
... 'C2',
... ('D1',
... 'E',
... 'D2',
... 'D3'),
... 'C3')))
>>> tree == copypasteoutput
True
>>>

View file

@ -0,0 +1,11 @@
>>> pprint(tree, width=60)
('a',
('b0',
('c1',
'c2',
('d', ('ef', 'gh')),
'c3',
('i1', 'i2', 'i3', 'jj', 'i4', ('kk', 'm'))),
'b1',
('C1', 'C2', ('D1', 'E', 'D2', 'D3'), 'C3')))
>>>

View file

@ -0,0 +1,38 @@
>>> mixedtree = ['a', ('b0', ('c1', 'c2', ['d', ('ef', 'gh')], 'c3', ('i1', 'i2',
... 'i3', 'jj', 'i4', ['kk', 'm'])), 'b1', ('C1', 'C2', ('D1', 'E',
... 'D2', 'D3'), 'C3'))]
>>> pprint(mixedtree, width=1)
['a',
('b0',
('c1',
'c2',
['d',
('ef',
'gh')],
'c3',
('i1',
'i2',
'i3',
'jj',
'i4',
['kk',
'm'])),
'b1',
('C1',
'C2',
('D1',
'E',
'D2',
'D3'),
'C3'))]
>>> pprint(mixedtree, width=60)
['a',
('b0',
('c1',
'c2',
['d', ('ef', 'gh')],
'c3',
('i1', 'i2', 'i3', 'jj', 'i4', ['kk', 'm'])),
'b1',
('C1', 'C2', ('D1', 'E', 'D2', 'D3'), 'C3'))]
>>>