| home | about me | feed RSS feed

The phrase "don't shadow a builtin" is often heard in the Python community.
How could this matter, you might ask?
Here's a simple example:

>>> list = list() # shadow a builtin (don't try at home)
>>> another_list = list()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>> del list
>>> another_list = list() # no error

So please take care when using—as variables—words that conflict with Python's "keywords".

created: 2010-06-07 | updated: 2011-03-12

Comments are now closed for this post.