[issue10702] bytes and bytearray methods are not documented
New submission from Alexander Belopolsky <belopolsky@users.sourceforge.net>: Library reference manual has a section dedicated to string methods [1], but similar methods of bytes and bytearray types are not documented. Adding two new sections would probably be too repetitious, so I wonder if it would make sense to add notes about byte/bytearray methods to the matching string methods' entries. See also issue10587. [1] http://docs.python.org/dev/py3k/library/stdtypes.html#string-methods ---------- assignee: docs@python components: Documentation messages: 123960 nosy: belopolsky, docs@python priority: normal severity: normal status: open title: bytes and bytearray methods are not documented versions: Python 3.2 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Éric Araujo <merwok@netwok.org> added the comment: I was persuaded there was already a bug open with a patch adding bytes and bytearray in the sequence methods table, but I can’t find it. ---------- nosy: +eric.araujo _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Alexander Belopolsky <belopolsky@users.sourceforge.net> added the comment:
I was persuaded there was already a bug open with a patch adding bytes and bytearray in the sequence methods table, but I can’t find it.
I can't find it either, but this issue is different. I propose renaming "String Methods" to "String, bytes and bytearray methods" and str.capitalize() bytes.capitalize() bytearray.capitalize() Return a copy of the string with its first character capitalized and the rest lowercased. [Discuss Unicode vs bytes details.] BTW, the "For 8-bit strings, this method is locale-dependent." part is probably out of date because bytes.capitalize() seems to pass non-ASCII bytes through:
bytes([ord('è')]).capitalize()[0] == ord('è') True
and for unicode strings the operation is *not* locale dependent. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Changes by Terry J. Reedy <tjreedy@udel.edu>: ---------- nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Changes by Xuanji Li <xuanji@gmail.com>: ---------- nosy: +xuanji _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Xuanji Li <xuanji@gmail.com> added the comment: Hi, it seems to me that section 4.6.5. Bytes and Byte Array Methods covers this already. It says: Bytes and bytearray objects, being “strings of bytes”, have all methods found on strings, with the exception of encode(), format() and isidentifier(), which do not make sense with these types. For converting the objects to strings, they have a decode() method. Wherever one of these methods needs to interpret the bytes as characters (e.g. the is...() methods), the ASCII character set is assumed. This section covers belpolsky's needs, ie a reader can, from this, understand that bytes have a capitalize method. However, I support 1) Expanding this section to explain more clearly what the methods do to bytes 2) Discuss unicode vs bytes details 3) Mention bytes and bytearrays in 4.6.1 String Methods, because it is quite far away from 4.6.5 As for the suggestion of renaming, if we rename the section, we have to decide what to call a string/byte/bytearray object because it now says, for example, str.something(); also we have to document the encode and decode methods seperately because they are not common to strings and bytes. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- nosy: +ezio.melotti, ncoghlan stage: -> needs patch type: -> enhancement versions: +Python 3.3, Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
Berker Peksag added the comment: Fixed in issue 21777. ---------- nosy: +berker.peksag resolution: -> out of date stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue10702> _______________________________________
participants (6)
-
Alexander Belopolsky
-
Berker Peksag
-
Ezio Melotti
-
Terry J. Reedy
-
Xuanji Li
-
Éric Araujo