Bug in PrettyPrinter?

D. R. Tzeck drt at un.bewaff.net
Fri Jan 25 05:04:50 EST 2002


If i understand PrettyPrinter right, is should output a valid
python expression. Printing a relativly simple nested dictionary

leads to lines like
  : 'Base station IP address''172.17.0.8',
which should be
  'Base station IP address': '172.17.0.8',
is this a possible bug or a misunderstanding on my side?

Exapmle (possibly mangled by shortening and MUA wort warp):

this code:

def printconf(airport):
    print airport
    pp = pprint.PrettyPrinter(indent=2)
    pp.pprint(airport)

leads to this output:

# repr
{'Checksum 1': '\'\\x02"\'', 'set password (?)': '',
'copyright': 'Copyright 1991 thru 2000 by Doug Karl and The Ohio
State University.', 'Base station IP address': '172.17.0.8',
'Access Control': [('ff:ff:ff:ff:ff:ff', 'X12345678901234567X'),
('aa:aa:aa:aa:aa:aa', 'XAAAAAAAAAAAAAAAAAX'),
('bb:bb:bb:bb:bb:bb', 'XBBBBBBBBBBBBBBBBBX'),
('cc:cc:cc:cc:cc:cc', 'XCCCCCCCCCCCCCCCCCX'),
('dd:dd:dd:dd:dd:dd', 'XEEEEEEEEEEEEEEEEEX'),
('ee:ee:ee:ee:ee:ee', 'XEEEEEEEEEEEEEEEEX')], 'Base
station partial mask': "'\\xff\\x00'", 'Base station name': 'frieda   '}

# pprint
{ 'Access Control': [ ('ff:ff:ff:ff:ff:ff','X12345678901234567X'),
                      ('aa:aa:aa:aa:aa:aa',
                      'XAAAAAAAAAAAAAAAAAX'),
                      ('bb:bb:bb:bb:bb:bb',
                      'XBBBBBBBBBBBBBBBBBX'),
                      ('cc:cc:cc:cc:cc:cc',
                      'XCCCCCCCCCCCCCCCCCX'),
                      ('dd:dd:dd:dd:dd:dd',
                      'XEEEEEEEEEEEEEEEEEX'),
                      ('ee:ee:ee:ee:ee:ee',
                      'XEEEEEEEEEEEEEEEEX')],
  : 'Base station IP address''172.17.0.8',
  : 'Base station name''frieda   ',
  : 'Base station partial mask'"'\\xff\\x00'",
  : 'Checksum 1''\'\\x02"\'',
  : 'Checksum 2'"'\\xe9\\x0e'",
  : 'copyright''Copyright 1991 thru 2000 by Doug Karl and The Ohio State University.',
  : 'set password (?)'''}


drt

-- 
teenage mutant ninja hero coders from da c0re - http://c0re.jp/
me                                  - http://koeln.ccc.de/~drt/



More information about the Python-list mailing list