Weird errors when trying to access a dictionary key
bdesth.quelquechose at free.quelquepart.fr
Thu Jul 19 06:43:04 CEST 2007
robinsiebler at gmail.com a écrit :
> I have a data structure that looks like this:
> I get the following error:
> AttributeError: 'list' object has no attribute 'keys'
> Here is where it gets weird:
> TypeError: 'str' object is not callable
You code snippet started with:
if type == 'artist':
which implies you bound the name 'type' to a string. Then you try to use
the object bound to name 'type' as a callable. Python's bindings are
just name=>object mappings, and nothing prevents you to rebind a builtin
name. IOW, avoid using builtins types and functions as identifiers.
More information about the Python-list