[python-win32] Repr, and Unicode type [Was: Get key press in Windows 7]

Werner wernerfbd at gmx.ch
Fri Nov 28 10:57:50 CET 2014


On 11/28/2014 9:46, John Sampson wrote:
> In answer to Time Roberts, I saw an item prefixed with 'u' (u'\x1a').
> What is the purpose of this prefix? I would have thought it meant
> 'Unicode' but the type according to Python is 'str'.
In Py2:
a = u'x'
type(a)
<type 'unicode'>

In Py3.4:
a = u'x'
type(a)
<class 'str'>

Note that u'' is not available in Py 3.0 - 3.2.

See e.g. here for more details:
https://docs.python.org/3/howto/pyporting.html?highlight=unicode%20literal#from-future-import-unicode-literals

Werner



More information about the python-win32 mailing list