[New-bugs-announce] [issue32677] Add str.isascii()

INADA Naoki report at bugs.python.org
Fri Jan 26 06:09:08 EST 2018


New submission from INADA Naoki <songofacandy at gmail.com>:

int() and str.is*** functions accepts other than ASCII.
But we want to accept only ASCII in some cases.  (e.g. ipaddress module)

We can use try-except to check ASCII, but it's inefficient.

try:
    s.encode('ascii')
except UnicodeEncodeError:
    ascii = False
else:
    ascii = True

CPython can check string is ASCII efficiently.

(Voting on python-ideas ML now)

----------
components: Interpreter Core
messages: 310754
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: Add str.isascii()
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32677>
_______________________________________


More information about the New-bugs-announce mailing list