On 10/15/07, Christian Heimes <[EMAIL PROTECTED]> wrote:
> I'm working on the renaming of str8 -> bytes and bytes -> buffer.
> PyBytes (old bytes, new buffer) can take a string together with an
> encoding and an optional error argument:
>
>
> >>> bytes(source="abc", encoding="ascii", errors="replace")
> b'abc'
> >>> str(b"abc", encoding="ascii")
> 'abc'
Correct.
> IMO this should work
> >>> str8("abc", encoding="ascii")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: 'encoding' is an invalid keyword argument for this function
Yes, this should work. (I thought it already did but was wrong. ;-)
> And this should break with a type error
> >>> str8("abc")
> b'abc'
Correct.
> PyString' constructor doesn't take strings (PyUnicode). I like to add
> the support for strings to it. It makes the API of str, bytes and buffer
> consistent and fixes a *lot* of broken code and tests.
Right.
> Are you confused by the name changes? I'm sometimes confused so I made a
> table:
>
> c name | old | new | repr
> -------------------------------------------
> PyUnicode | str | - | ''
> PyString | str8 | bytes | b''
> PyBytes | bytes | buffer | buffer(b'')
I'd rewrite this as follows:
C name | 2.x | 3.0a1 | 3.0a2 |
----------+--------------+------------+---------------------+
PyUnicode | unicode u"" | str "" | str "" |
PyString | str "" | str8 s"" | bytes "" |
PyBytes | N/A | bytes b"" | buffer buffer(b"") |
----------+--------------+------------+---------------------+
Seems worth adding to the PEP. I'll do that.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com