Why isn't 'list' a reserved word in Python?

后端 未结 4 1313
無奈伤痛
無奈伤痛 2020-12-11 20:14

I just got bit by a bug that would have been prevented if list were a reserved word in Python. (Dumbery on my part, to be sure.)

So why isn\'t list (or

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 20:35

    Have a look at this: http://docs.python.org/2/reference/lexical_analysis.html#keywords

    list is simply a type and is not reserved (neither is int, float, dict, str... you get the point).

提交回复
热议问题