Reversing \N{...} notation?
Tim Chase
python.list at tim.thechases.com
Wed Oct 26 14:35:10 EDT 2016
On 2016-10-25 20:14, Peter Otten wrote:
> Tim Chase wrote:
> > I like the clarity of using the "\N{...}" notation when creating
> > string literals involving Unicode chars.
> >
> > Is there a built-in way to get such strings back from Python?
>
> >>> 'maƱana'.encode("ascii", "namereplace").decode()
> 'ma\\N{LATIN SMALL LETTER N WITH TILDE}ana'
Wonderful! Thanks for knowing about that corner of Python and
sharing it.
> (requires Python 3.5)
Sorry it wasn't back-ported, but glad it's there now. Thanks!
-tkc
More information about the Python-list
mailing list