Skip to content

Commit

Permalink
PEP 467: add more explanation to bytes.ascii()
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfurman committed Nov 4, 2021
1 parent c85dbf3 commit b9655e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pep-0467.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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
------------------------------------------------------
Expand Down

0 comments on commit b9655e3

Please sign in to comment.