python-mastery
python-mastery copied to clipboard
Slide 1-12: Variable names can contain non-ascii characters
The slide states:
Variable names follow same rules as C [A-Za-z_][A-Za-z0-9_]*
However, since Python 3.0 variable names can also contain non-non-ASCII letters (such as accented characters, Cyrillic, Greek, Kanji, etc.).
https://docs.python.org/3/reference/lexical_analysis.html#identifiers
https://peps.python.org/pep-3131/
Yes, but it's meant to be a "quick review", not an exhaustive language reference that overwhelms everyone. Most code follows the convention described.
Just say “variable names can be made up of digits and letters from most of the major languages of the world”.
Advanced Python Mastery
Hey @dabeaz, I've realized I've never thanked you for the slides -- thank you! They look great.
I agree keeping variable names under [A-Za-z_][A-Za-z0-9_]*
is a best practice; although I do not think that your great slides should state incorrect facts. Even adding an asterisk may probably be enough here, expecting a presenter to acknowledge the spec is broader than described. Or, explaining that UTF-8 chars are allowed as long as they represent letters can play into the narrative of Python being "UTF-8 native" which you bring up in later slides, I believe.
If you disagree, please feel free to close the issue, no offence would be taken.
- [x] __
Added an extra slide to explain a bit more on names.