[issue32677] Add str.isascii()

2018-01-26 Thread INADA Naoki
Change by INADA Naoki : -- keywords: +patch pull_requests: +5188 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list

[issue32677] Add str.isascii()

2018-01-26 Thread STINNER Victor
STINNER Victor added the comment: > (Voting on python-ideas ML now) https://mail.python.org/pipermail/python-ideas/2018-January/048737.html -- nosy: +vstinner ___ Python tracker _

[issue32677] Add str.isascii()

2018-01-26 Thread INADA Naoki
New submission from INADA Naoki : 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