Where does "\ n {SPECIAL CHARACTER}" come from in Python?

I started to feel comfortable with Python until I came across some urwid tutorial that included an example with code like this

 ... main = urwid.Padding(menu(u'Pythons', choices), left=2, right=2) top = urwid.Overlay(main, urwid.SolidFill(u'\N{MEDIUM SHADE}'), align='center', width=('relative', 60), valign='middle', height=('relative', 60), min_width=20, min_height=9) urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run() 

This u'\N{MEDIUM SHADE}' string literal drove me nuts almost all day until I found out that it was included - as comments! - in the files under /usr/lib/python3.5/encodings/ ... But nowhere have I found a hint of the use of such designations. I went through the Python documentation and found nothing. Even a hint!

Now I feel like n00b. Again. I believe that there are many more features that I have missed so much ... because they are not mentioned anywhere - or at least in an obvious and wonderful place.

Out of curiosity, I ran into my python interpreter:

 print(u'\N{LOWER ONE QUARTER BLOCK}') 

and i got

  

Where does such black magic come from? I mean, where does this explain, can I use this ... notation (?) To print special characters using their friendly names? Does Python hide any other surprises like this?

+7
python special-characters string-literals
source share
1 answer

At the end of https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals :

\ n {name} - The named name of the character in the Unicode database

+10
source share

All Articles