python-mastery icon indicating copy to clipboard operation
python-mastery copied to clipboard

Slide 1-12: Variable names can contain non-ascii characters

Open mingaleg opened this issue 1 year ago • 4 comments

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/

mingaleg avatar Jul 21 '23 12:07 mingaleg

Yes, but it's meant to be a "quick review", not an exhaustive language reference that overwhelms everyone. Most code follows the convention described.

dabeaz avatar Jul 21 '23 12:07 dabeaz

Just say “variable names can be made up of digits and letters from most of the major languages of the world”.

Advanced Python Mastery

ldo avatar Jul 23 '23 08:07 ldo

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.

mingaleg avatar Jul 25 '23 21:07 mingaleg

  • [x] __

Hobika123 avatar Jul 30 '23 18:07 Hobika123

Added an extra slide to explain a bit more on names.

dabeaz avatar Jul 31 '24 15:07 dabeaz