Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'python': 0.09; '[0,': 0.09; 'collections': 0.09; 'defaultdict': 0.16; 'pprint': 0.16; 'import': 0.21; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'record': 0.28; 'cat': 0.29; 'subject:per': 0.29; 'print': 0.32; '11,': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; '12,': 0.36; 'received:209': 0.37; 'some': 0.38; 'to:addr:python.org': 0.39; 'subject:record': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=IRtPG9rTspvfVweVi8G7+ywyzGial9pYXztD1u8fgOg=; b=OuLXlVP3FveRKLY+r87vmqVoL41dymmzD5x7VI7ImxJXFyb4HQkj6rJmHzSx5nDxRJ hRovBzaf5lpqUq+S/qafCoUi3NKnnfhzLl/7kXBTlKNF8id9SRAXyrU7BOuQvnxmmkCz LUkRPkTNQHWW6CL8c9bS7XE7oFgHjCXRx10CmRNne/ZTjJU06zwQHDogI2U1IH5ZMfIw uqLzdJRLfHTBrguHB0YJxPSfWXrBMVbflgGLzjQCU60FG1CyjG+oZthu52BbpQpixlmC CnsihgjnrbCD2rmN5kP1xir8Zr7NSSTVt193kedj6J1iBdYOtymrNISFSWmwmPWLw0XX 2JKg== MIME-Version: 1.0 X-Received: by 10.224.181.210 with SMTP id bz18mr15890973qab.68.1363542326545; Sun, 17 Mar 2013 10:45:26 -0700 (PDT) Date: Sun, 17 Mar 2013 12:45:26 -0500 Subject: pprint defaultdict one record per line From: Peng Yu To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363542329 news.xs4all.nl 6940 [2001:888:2000:d::a6]:34836 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41363 Hi, pprint can not print defaultdict one record per line. Is there some other convenient way in python to print one record per line? ~/linux/test/python/man/library/pprint/function/pprint$ ./main.py {'two': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 'one': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]} {'one': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 'two': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]} defaultdict(, {'two': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 'one': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}) ~/linux/test/python/man/library/pprint/function/pprint$ cat main.py #!/usr/bin/env python import pprint d=dict(one=range(10), two=range(15)) print d pprint.pprint(d) from collections import defaultdict d=defaultdict(list) d['one']=range(10) d['two']=range(15) pprint.pprint(d) -- Regards, Peng