On Sun, Feb 5, 2017 at 10:49 PM, Cameron Simpson <c...@zip.com.au> wrote:
> On 05Feb2017 22:27, boB Stepp <robertvst...@gmail.com> wrote:
>>
>> On Sun, Feb 5, 2017 at 7:23 PM, Steven D'Aprano <st...@pearwood.info>
>> wrote:
>>>
>>> Alternatively, you can embed it right in the string. For code points
>>> between U+0000 and U+FFFF, use the \u escape, and for the rest, use \U
>>> escapes:
>>>
>>> py> 'pi = \u03C0'  # requires exactly four hex digits
>>> 'pi = π'
>>>
>>> py> 'pi = \U000003C0'  # requires exactly eight hex digits
>>> 'pi = π'
>>>
>>>
>>> Lastly, you can use the code point's name:
>>>
>>> py> 'pi = \N{GREEK SMALL LETTER PI}'
>>> 'pi = π'
>>
>>
>> You have surprised me here by using single quotes to enclose the
>> entire assignment statements.  I thought this would throw a syntax
>> error, but it works just like you show.  What is going on here?
>
>
> It's not an assignment statement. It's just a string. He's typing a string
> containing a \N{...} sequence and Python's printing that string back at you;
> pi's a printable character and gets displayed directly.

I just came out of the shower this morning thinking, "Stupid boB,
stupid.  That's just an escape sequence inside an overall string, not
an assignment statement."  Duh!  My brain works better asleep than
awake...

boB
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to