[Python-ideas] isascii()/islatin1()/isbmp()

Antoine Pitrou solipsis at pitrou.net
Sat Jun 30 18:43:16 CEST 2012

On Sun, 1 Jul 2012 02:14:23 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sun, Jul 1, 2012 at 2:03 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> > As shown in issue #15016 [1], there is a use cases when it is useful to
> > determine that string can be encoded in ASCII or Latin1. In working with Tk
> > or Windows console applications can be useful to determine that string can
> > be encoded in UCS2. C API provides interface for this, but at Python level
> > it is not available.
> >
> > I propose to add to strings class new methods: isascii(), islatin1() and
> > isbmp() (in addition to such methods as isalpha() or isdigit()). The
> > implementation will be trivial.
> Why not just expose max_code_point directly instead of adding three new methods?

Because it's really an implementation detail. We don't want to carry
around such a legacy.
Besides, we don't know the max code point for sure, only an upper bound
of it (and, implicitly, also a lower bound).

So while I'm -0 on the methods (calling encode() is as simple), I'm -1
on max_code_point.



More information about the Python-ideas mailing list