On Mon, Jun 2, 2008 at 2:39 AM, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > On Sun, Jun 1, 2008 at 11:32 AM, Atsuo Ishimoto <[EMAIL PROTECTED]> wrote: >> >> ---------------------------------------------- >> PEP: 3138 >> >> Title: String representation in Python 3000 >> Version: $Revision$ >> Last-Modified: $Date$ >> Author: Atsuo Ishimoto <ishimoto--at--gembook.org> >> Status: Draft >> Type: Standards Track >> Content-Type: text/x-rst >> Created: 05-May-2008 >> Post-History: >> > [SNIP] >> - Add a new function to the Python C API ``int PY_UNICODE_ISPRINTABLE >> (Py_UNICODE ch)``. > > Shouldn't the name be Py_UNICODE_ISPRINTABLE?
Oh, yes. It has correct name in the patch. > > I know that I am a bit late in the whole discussion, but isn't, > whether or not a character is "printable", actually defined as a > property of the output device (i.e., does it have the necessary glyphs > to render the characters)? > > I don't have a problem with allowing more characters to be represented > unescaped (in fact, I think this is a great idea). But, I just don't > like using "printable" as a character property. Maybe, "readable" or > "legible" would be more appropriate. Anyway, that's only nitpicking > from my part. > I'm not comfortable with "printable", too. Is "legible" better? This is first time for me to see this word in my life :). >> - Add ``'%a'`` string format operator. ``'%a'`` converts any python >> object to a string using repr() and then hex-escapes all non-ASCII >> characters. The ``'%a'`` format operator generates the same string as >> ``'%r'`` in Python 2. >> >> - Add a new built-in function, ``ascii()``. This function converts any >> python object to a string using repr() and then hex-escapes all non- >> ASCII characters. ``ascii()`` generates the same string as ``repr()`` >> in Python 2. >> > > Why ascii() has to use repr()? Couldn't we simply rename the old 2.x > repr() function to ascii()? No. repr() simply calls obj.__repr__(), and obj.__repr() returns non-ASCII string now. So to get ASCII string, we should convert result of repr(). > >> - Add an ``isprintable()`` method to the string type. ``str.isprintable()`` >> returns False if repr() should escape any character in the string; >> otherwise returns True. The ``isprintable()`` method calls the >> `` PY_UNICODE_ISPRINTABLE()`` function internally. >> > > Quick thought, what should become of string.printable? Should it be > renamed to string.ascii_printable or removed? > I agree string.ascii_printable is better name, but I'm not motivated enough to break compatibility. > Overall, I think the PEP is good. So, +1 from me. Thank you! _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com