Weird errors when trying to access a dictionary key

Bruno Desthuilliers bdesth.quelquechose at
Thu Jul 19 00:43:04 EDT 2007

robinsiebler at a écrit :
> I have a data structure that looks like this:
> I get the following error:
> AttributeError: 'list' object has no attribute 'keys'

Already answered.

> Here is where it gets weird:
> type(song)
> 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 mailing list