est wrote:
>>From python manual
> 
> str( [object])
> 
> Return a string containing a nicely printable representation of an
> object. For strings, this returns the string itself. The difference
> with repr(object) is that str(object) does not always attempt to
> return a string that is acceptable to eval(); its goal is to return a
> printable string. If no argument is given, returns the empty string,
> ''.
> 
> 
> now we try this under windows:
> 
>>>> str(u'\ue863')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\ue863' in
> position 0
> : ordinal not in range(128)

In 3.0 this is fixed:
>>> str('\ue863') # u prefix is gone
'\ue863'
>>> str(b'123') # b prefix is added
"b'123'"

Problems like this at least partly motivated the change to unicode
instead of bytes as the string type.

tjr

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to