problem with dictionaries

2008-04-23 Thread Simon Strobl
Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The value frq[key] is

Re: problem with dictionaries

2008-04-23 Thread Peter Otten
Simon Strobl wrote: the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The

Re: problem with dictionaries

2008-04-23 Thread Chris
On Apr 23, 1:16 pm, Simon Strobl [EMAIL PROTECTED] wrote: Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times.

Re: problem with dictionaries

2008-04-23 Thread kdwyer
On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote: Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many

Re: problem with dictionaries

2008-04-23 Thread Steve Holden
Simon Strobl wrote: Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The

Re: problem with dictionaries

2008-04-23 Thread Bruno Desthuilliers
kdwyer a écrit : On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote: (snip) #!/usr/bin/python import sys frqlist = open('my_frqlist.txt', 'r') (snip) frq = {} for line in frqlist: line = line.rstrip() frequency, word = line.split('|') frq[word] = int(frequency) (snip)

Re: problem with dictionaries

2008-04-23 Thread kdwyer
On Apr 23, 1:22 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: kdwyer a écrit : On Apr 23, 12:16 pm, Simon Strobl [EMAIL PROTECTED] wrote: (snip) #!/usr/bin/python import sys frqlist = open('my_frqlist.txt', 'r') (snip) frq = {} for line in frqlist: line =

Re: problem with dictionaries

2008-04-23 Thread Simon Strobl
flippancyYou musts have missed the memo. The rules of the universe changed at 0834 UST yesterday, and all functioning Python programs stopped working./flippancy As always, the rules of the universe have not changed. (Or, at least, I do hope so.) It seems that the cause of my problem was my

Re: problem with dictionaries

2008-04-23 Thread Terry Reedy
Simon Strobl [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Any hints? For future reference, I would consider using sample data in the file itself for debugging -- to separate an algorithm problem from a file problem: | | |

Re: Problem in Dictionaries

2005-03-02 Thread Terry Reedy
Glauco Silva [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I would like to know if the dictionary can sort with a function that i give to then! No. You have to either make a list of key,value items and sort that, possibly with a cmp or key parameter items = d.items()

Problem in Dictionaries

2005-03-01 Thread Glauco Silva
I´m with problem inDictionaries ! I would like to know if the dictionary can sort with a function that i give to then! Because i need to have a dictionary sort by key ! For exemple : dict = {} dict[50] = "fifty" dict[129] = "a hundred twenty nine" print dict {129: "a hundred twenty nine", 50: