Is it possible to escape a reserved word in Python?

前端 未结 5 1596
一整个雨季
一整个雨季 2020-12-18 04:36

It may not be a good idea to name a variable after a reserved word, but I am curious:

Is there any escape syntax in Python to allow you to use a reserved word as the

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 05:22

    No, this is not possible.

    Section 2.3.1 of The Python Language Reference says that keywords 'cannot be used as ordinary identifiers' and does not specify an escape syntax.

    This is probably a Good Thing, for the sake of code readability!

提交回复
热议问题