This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年09月18日 17:41 by terry.reedy, last changed 2022年04月11日 14:57 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg144247 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年09月18日 17:41 | |
From python-ideas thread "truncate sequences in pretty-print ?"
On Sat, Sep 17, 2011 at 9:59 PM, Steven Samuel Cole
> i use pprint quite a bit during development to give me quick insight
> into what is going on inside my application.
> however, when there's any sequences involved, the output becomes less
> useful the longer these sequences are - i often find myself scrolling
> around (or even searching) in the terminal window, trying to find the
> bit of output i am interested in.
>
> imo, it would be great if pprint had a parameter 'max_len' or so that
> reduces output of every sequence to a maximum and inserts something
> like '...' to indicate truncation, e.g.
> {'my key': ['my list item 01',
> 'my list item 02',
> 'my list item 03',
> 'my list item 04',
> 'my list item 05',
> 'my list item 06',
> 'my list item 07',
> 'my list item 08',
> '...',
> 'my list item 10',]}
>
> somewhat comparable to the '...' already printed when a structure is
> more deeply nested than you want to know right now.
On 9/18/2011 10:59 AM, Guido van Rossum wrote:
Agreed, this would be a useful feature. I've reimplemented something
like pprint a few times and always had to implement this truncation
feature. If you or someone can contribute a patch that would be much
appreciated!
|
|||
| msg144316 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2011年09月20日 03:17 | |
This needs to be part of the overall effort to build a better pprint. See http://bugs.python.org/issue7434 |
|||
| msg144319 - (view) | Author: anand jeyahar (anandjeyahar) | Date: 2011年09月20日 05:43 | |
Umm... Excuse me but how is this max_length parameter different from the (existing)depth parameter? pformat(object,depth=3) seems to do the same thing. |
|||
| msg144365 - (view) | Author: Steven Samuel Cole (ssc) | Date: 2011年09月21日 03:49 | |
@anand: as the names say, the depth parameter limits the depth of display while the length parameter limits the length. for example, with a data structure of a list of lists of lists and a depth of 2, only the first two levels would be shown, the third list at the 'bottom' would be replaced by '...' on the other hand, in a list with 10 entries and a length parameter of 5, only 5 list entries would be displayed. @Raymond: agreed. i have squeezed max_len into the existing code and ported that back to 2.6 for my current project; while it works, it is a bad hack. i would much more prefer bundling efforts into an extensible pprint rewrite. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:21 | admin | set | github: 57213 |
| 2013年07月12日 06:31:16 | rhettinger | set | assignee: rhettinger -> |
| 2011年12月15日 17:20:33 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola |
| 2011年09月21日 03:49:55 | ssc | set | messages: + msg144365 |
| 2011年09月20日 08:33:57 | ncoghlan | set | dependencies: + general pprint rewrite |
| 2011年09月20日 05:43:21 | anandjeyahar | set | nosy:
+ anandjeyahar messages: + msg144319 |
| 2011年09月20日 03:17:46 | rhettinger | set | assignee: rhettinger messages: + msg144316 nosy: + rhettinger |
| 2011年09月19日 20:32:59 | santoso.wijaya | set | nosy:
+ santoso.wijaya |
| 2011年09月19日 09:22:42 | ssc | set | nosy:
+ ssc title: pprint: add option to truncate seqeunces -> pprint: add option to truncate sequences |
| 2011年09月18日 17:42:01 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2011年09月18日 17:41:13 | terry.reedy | create | |