Why can't class attributes be named as reserved words in python?
问题 It seems reserved words can not be used as attributes in python: $ python Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A: >>> global = 3 File "<stdin>", line 2 global = 3 ^ SyntaxError: invalid syntax This seems sensible, since it is ambiguous: am I using the global keyword here? Difficult to say. But this is not sensible imho: >>> class