Yes, others are saying above, don't use the name of a builtin as a variable name. This goes for list
, dict
, etc.
Likewise, as others have said, you have access to the type list
through __builtins__.list
. So if you need to call list
, you can still find it, as long as you haven't rebound __builtins__.list
also.
Importantly, though, list
is a name. You've rebound it to an instance of a list. If you want list
to mean <type 'list'>
again, just rebind it again. In Python 2.7:
>>> __builtins__.list
<type 'list'>
>>> list
<type 'list'>
>>> list = [1, 2, 3]
>>> list
[1, 2, 3]
>>> fred = list
>>> fred
[1, 2, 3]
>>> list = __builtins__.list
>>> list
<type 'list'>