Good modernization advice from Terry J. Reedy:
Don't use list, dict, file, and such as variable names.
This commit is contained in:
parent
87e4c7b2c1
commit
f6e3df20d0
15
pep-0290.txt
15
pep-0290.txt
|
@ -180,6 +180,21 @@ sufficient for most uses.
|
|||
Locating: ``grep types *.py | grep import``
|
||||
|
||||
|
||||
Avoid Variable Names that Clash with the ``__builtins__`` Module
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
In Python 2.2, new built-in types were added for ``dict`` and ``file``.
|
||||
Scripts should avoid assigning variable names that mask those types.
|
||||
The same advice also applies to existing builtins like ``list``.
|
||||
|
||||
Pattern::
|
||||
|
||||
file = open('myfile.txt') --> f = open('myfile.txt')
|
||||
dict = obj.__dict__ --> d = obj.__dict__
|
||||
|
||||
Locating: ``grep 'file ' *.py``
|
||||
|
||||
|
||||
Python 2.1 or Later
|
||||
-------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue