[issue12380] bytearray methods center, ljust, rjust don't accept a bytearray as the fill character

R. David Murray report at bugs.python.org
Wed Jun 22 00:51:48 CEST 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

A bytearray is for working with mutable data.  We don't support using it in all places that the non-mutable data types can be used.  You can code your example like this:

   barr.center(len(barr) * 4, bytes([barr[-1]]))

I realize that isn't particularly pretty, but that has more to do with the fact that indexing bytes gives you ints in Python 3 than it does with whether or not bytearray is accepted.

The data type of the arguments to the method have no necessary relationship with the datatype of the object.

You may have more success arguing that the fill character for both bytearray and bytes should be allowed to be an int.

I think this whole topic is better addressed in a forum such as python-ideas.  I agree that the bytes interface is a bit wonky in places, but I think that if changes are going to be made a consensus needs to be developed on what changes to make.  I believe some conversations about this have already taken place, and so far I don't think there are any consensus proposals.

So, I'm going to close this issue.  But please join (or start, if necessary) the discussion on this wider topic in the appropriate forum.

----------
resolution:  -> rejected
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12380>
_______________________________________


More information about the Python-bugs-list mailing list