Python 3, an Illustrated Tour Transcripts
Chapter: Strings
Lecture: Unicode Variable Names
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
This video will talk about Unicode identifiers. These came out in Python 3, and PEP 3131 introduced them.
0:09
The PEP states: by using identifiers in their native language code clarity and maintainability of the code among speakers of that language improves.
0:18
What does this mean? It means that I can use a unicode character such as Ω I can say the Ω_val=10 if I'm talking about resistance or whatnot
0:28
and then I can ask for that variable and Python 3 will give that to me. Note that Python 2 does not like this and this won't work in Python 2.
0:37
Still have some issues, you can't start a variable with a number so I can't say to 2Ω_val, I'll get a syntax error there.
0:45
That's basically all I have to say about unicode variables. I personally haven't seen them that often.
0:50
I'm in the United States and I mostly deal in an ASCII centric world. One other thing that the PEP notes
0:57
is that the Python language isn't going to use unicode variables either. So even though the language supports it
1:02
and an effort to make things simpler and easier for everyone to type and understand it's just going to stick with ASCII variables.
1:10
So I personally haven't seen anyone using this feature, though it's out there. So if you've got a cool example, I'd love to see it.
1:17
Hit me up on Twitter or whatnot and let me know of a useful example where this is being used.