Re: Weird errors when trying to access a dictionary key

2007-07-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I have a data structure that looks like this: > (snip) > > I get the following error: (snip) > AttributeError: 'list' object has no attribute 'keys' Already answered. > Here is where it gets weird: > > type(song) (snip) > TypeError: 'str' object is not callable Y

Re: Weird errors when trying to access a dictionary key

2007-07-20 Thread Ben Finney
[EMAIL PROTECTED] writes: > I have a data structure that looks like this: > [...] > rpt_file.writelines('\t' + [song].keys() + '\t' + [song].values() + '\n') Forms the list [song] twice, attempting to call the 'keys()' method and the 'values()' method of that list in turn... > I get the followin

Re: Weird errors when trying to access a dictionary key

2007-07-20 Thread robinsiebler
Ignore my previous response. :p I figured out what my problem was. I had [song].keys() when I really meant song.keys() and really needed str(song.keys()). I just got a little too bracket happy. :p -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird errors when trying to access a dictionary key

2007-07-20 Thread robinsiebler
> You are converting the dictionary to a list on this line, and lists do > not have keys> rpt_file.writelines('\t' + > [song].keys() \ > How am I converting it to a list? > Note the first line has braces, not brackets so it is a > dictionary. Braces? What 1st line

Re: Weird errors when trying to access a dictionary key

2007-07-20 Thread Zentrader
> rpt_file.writelines('\t' + [song].keys() \ > + '\t' + > I get the following error: > > Traceback (most recent call last): > AttributeError: 'list' object has no attribute 'keys' All of these messages are correct. The fi

Weird errors when trying to access a dictionary key

2007-07-20 Thread robinsiebler
I have a data structure that looks like this: #dates = {'2007': {'25': {'06/23/07': {'aerosmith': [{'sweet emotion': 1}, {'dream on': 2}], # 'Metallica': [{'Fade to Black': 1}, {'Master of Puppets': 1}]}, # 'last_song': [Master of Puppets',