Naming conflict with built-in function

Step one: rebind the list to a different name

lst = list

Step two: delete the list variable

del list

Step three: don’t do it again


I prefer this over __builtins__.list simply because it saves the typing, and you aren’t still left with a variable named list. However, it is always best to avoid the problem altogether. When writing production code, always remember not to have variables named the same as built in functions.

Leave a Comment