Issue 3252: str.tobytes() and bytes/bytearray.tostr() (original) (raw)

Issue3252

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.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/47502

classification

Title: str.tobytes() and bytes/bytearray.tostr()
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.0

process

Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, lemburg, mark
Priority: normal Keywords:

Created on 2008-07-01 15:39 by mark, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg69047 - (view) Author: Mark Summerfield (mark) * Date: 2008-07-01 15:39
I know it is almost certainly too late, but I think a lot of people will be confused by str.decode() and bytes.encode() (or was that the other way around)? Calling the methods str.tobytes() and bytes.tostr() (or nicer, str.to_bytes() and bytes.to_str()) would be hard to confuse and IMO will lead to fewer bug reports and complaints once Python 3.0 final comes out. And there is a kind of precedent in that threading.isDaemon() became threading.is_daemon() between 30a5 and 30b1.
msg69048 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-07-01 15:54
-1 encoding and decoding is generally accepted terminology. Besides then we would be binding ourselves to returning bytes or a str; that's not necessarily guaranteed. Anyway, I think this hardly has a chance in the place we are (between betas).
msg69049 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-01 16:04
> encoding and decoding is generally accepted terminology Yes, but I personally always pause a couple of seconds each time I have to write "encode" or "decode". Following Mark's idea, I think I will mentally use "en-bytes" and "de-bytes" as a mnemonic...
msg69052 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2008-07-01 17:17
There's nothing new to .encode() and .decode(). They have existed since Python 1.6.
History
Date User Action Args
2022-04-11 14:56:36 admin set github: 47502
2008-07-01 17:17:52 lemburg set status: open -> closedresolution: wont fixmessages: + nosy: + lemburg
2008-07-01 16:04:03 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2008-07-01 15:54:14 benjamin.peterson set nosy: + benjamin.petersonmessages: +
2008-07-01 15:39:11 mark create