"Newbie" questions - "unique" sorting ?

Cousin Stanley CousinStanley at hotmail.com
Tue Jul 1 01:17:43 EDT 2003


| ...
| Bye the way Cousin Stanley I assume the numbers
| in the final result were how many times that string
| appeared in the input file ?
|
| A very interesting number to have.
|
| When I get time though I might "rem" (is that # ?) out
| that/those line/lines so that I have a second URL sorting
| python executable that doesn't include the numbers.
|
| Assuming I can work out which one(s) to disable !

John ...

Getting rid of the word_count
isn't too bad ....

Find the following code block in word_list.py ....

for this_word in list_words :

    word_count = dict_words[ this_word ]

    str_out    = '%6d %s %s' % ( word_count , this_word , NL )

    file_out.write( str_out )


Change the above 4 lines to the following 2 ....

for this_word in list_words :

    file_out.write( this_word + NL )

Save the changed file to word_list2.py ....


As an alternative, since the words you are interested in
in this application are actually URLs, you might want
to generate actual clickable HTML links ....

for this_word in list_words :

    file_out.write( '<a href="' + this_word + '">' + NL )

    file_out.write( this_word + NL )

    file_out.write( '</a>' + NL + NL )

Save the changed file to word_list3.py ....

I haven't tested either of the above changes,
but this should provide some ideas ....

-- 
Cousin Stanley
Human Being
Phoenix, Arizona






More information about the Python-list mailing list