Bugs item #1734723, was opened at 2007-06-11 02:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1734723&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jason Roberts (jasonjroberts)
Assigned to: Nobody/Anonymous (nobody)
Summary: Repr class from repr module ignores maxtuple attribute

Initial Comment:
The Repr class from the repr module is supposed limit the number of tuple items 
dumped to the value of the maxtuple attribute. But it uses the value of the 
maxlist attribute instead:

    def repr_tuple(self, x, level):
        return self._repr_iterable(x, level, '(', ')', self.maxlist, ',')

As a result:

>>> import sys
>>> sys.version
'2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]'
>>> import repr
>>> r = repr.Repr()
>>> r.maxtuple
6
>>> r.maxlist
6
>>> r.maxtuple = 3
>>> r.repr((1,2,3,4,5,6,7,8,9))         # Will print 6 items, not 3
'(1, 2, 3, 4, 5, 6, ...)'
>>> r.maxlist = 3
>>> r.repr((1,2,3,4,5,6,7,8,9))         # Now will print 3 items
'(1, 2, 3, ...)'

The implementation of repr_tuple should be changed to:

    def repr_tuple(self, x, level):
        return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',')

Obviously this is not a major issue if nobody has noticed it by now. But it 
would be nice to correct the implementation to match the documentation.

In my scenario, I want to dump out all of the items of a tuple but only three 
items from any embedded list. Something like this:

>>> x = (......)
>>> import repr
>>> r = repr.Repr()
>>> r.maxtuple = 255
>>> r.maxlist = 3
>>> print r.repr(x)

But because maxlist controls both the dumping of lists and of tuples, I have to 
choose between only dumping a few items of the tuple and having small lists, or 
dumping all of the items in the tuple and having large lists.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1734723&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to