Author terry.reedy
Recipients docs@python, ncoghlan, petri.lehtinen, pitrou, py.user, r.david.murray, rhettinger, terry.reedy, vstinner
Date 2011-06-23.00:08:32
SpamBayes Score 9.12181e-12
Marked as misclassified No
Message-id <1308787713.82.0.965364938515.issue12380@psf.upfronthosting.co.za>
In-reply-to
Content
After thinking about this awhile, I see the key sentence of David's reply as "The data type of the arguments to the method have no necessary relationship with the datatype of the object." While true in general, in it not true with respect to corresponing text (string) and byte(array) methods. String parameters of strings methods become byte parameters of byte(array) methods. In the other hand, I think I agree with David's application to byte versus bytearray methods. I might change my mind after further examination of the methods in question. But for the present, I would not change the code.

Or would I? Here is a reason not to change. Example:

for byt in (b'abc', bytearray(b'cdef'), b'xye')
  yield byt.rjust(10,b'-')

Making the type of constant args depend on the type of the base object would make generic byte/bytearray functions more difficult. We already have this problem with writing functions that work with bytes and text in 3.x. It is a big nuisance that is only justified by the benefits of not mixing bytes and text. I do not think we should extend the nuisance to byte and bytearray functions, especially without a strong use case.

I marked this for 'documentation' because I think the doc for some of the str methods might be improved and that the reference to them in the bytes/bytearray definitely needs more. Doc changes would apply to 3.2 also.

"Bytes and bytearray objects, being “strings of bytes”, have all methods found on strings, with the exception ... " 

should be followed by something like. 

"If the string method has a string parameter, the corresponding byte/bytearray method has a corresponding byte parameter."

(to match the reported current behavior).

I have not yet looked at doc strings. I did not unmark 'Interpreter core' because I have not looked at all of p.u's examples to be sure that I like *all* of the current behaviors.
History
Date User Action Args
2011-06-23 00:08:33terry.reedysetrecipients: + terry.reedy, rhettinger, ncoghlan, pitrou, vstinner, r.david.murray, docs@python, py.user, petri.lehtinen
2011-06-23 00:08:33terry.reedysetmessageid: <1308787713.82.0.965364938515.issue12380@psf.upfronthosting.co.za>
2011-06-23 00:08:33terry.reedylinkissue12380 messages
2011-06-23 00:08:32terry.reedycreate