PEP 467: add more explanation to `bytes.ascii()`

This commit is contained in:
Ethan Furman 2021-11-03 23:32:54 -07:00
parent c85dbf3c8e
commit b9655e3ba7
1 changed files with 10 additions and 0 deletions

View File

@ -130,6 +130,10 @@ Python 2 ``str``) was as simple as::
With Python 3 that became the more verbose::
>>> b'%d' % 123
or even::
>>> str(123).encode('ascii')
This PEP proposes that an ``ascii`` method be added to ``bytes`` and ``bytearray``
@ -138,6 +142,12 @@ to handle this use-case::
>>> bytes.ascii(123)
b'123'
Note that ``bytes.ascii()`` would handle simple ascii-encodable text correctly,
unlike the `ascii()`` built-in::
>>> ascii("hello").encode('ascii')
b"'hello'"
Addition of "getbyte" method to retrieve a single byte
------------------------------------------------------