Sep-01-2018, 10:05 AM
(This post was last modified: Sep-01-2018, 10:06 AM by Gribouillis.)
(Sep-01-2018, 08:40 AM)j.crater Wrote: type is a reserved Python keywordTechnically speaking,
type
is not a keyword and it is perfectly legal to use it, however it is a well known builtin function, like list, dict, open
, and nobody expects a different meaning for this variable when reading a python program. It is indeed better to rename it.For a list of keywords (which you cannot use as variable names) see
>>> import keyword >>> keyword.kwlist ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']For a list of builtin names to avoid
>>> sorted(vars(__builtins__)) ['ArithmeticError', 'AssertionError', ..., 'type', 'vars', 'zip']