On 1/12/2017 12:10 PM, Victor Stinner wrote:

Ah yes, date, thank you for the example. Here is my example using
LC_TIME locale to format a date and LC_CTYPE to decode a byte string:

date.py:
---
import locale, time
locale.setlocale(locale.LC_ALL, "")
b = time.strftime("%a")
encoding=locale.getpreferredencoding()
try:
    u = b.decode(encoding)
except UnicodeError:
    u = '<failed to decode>'
else:
    u = repr(u)
print("bytes: %r, text: %s, encoding: %r" % (b, u, encoding))

Since b is a string, b.decode is an AttributeError on 3.x. What am I missing? Was this for 2.x only?

--
Terry Jan Reedy

_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to