sorting

Fernando Pérez fperez528 at yahoo.com
Fri Mar 1 02:17:33 EST 2002


"Jeff McComas" <jmackd1 at yahoo.com> wrote

> As a newbie i find the python scripting language very interesting and
useful.
> I am trying to write a script that will search a .txt file and have the
script
> tell me how many of the same numbers are in the .txt file. I know you can
do
> it with the f.count command but my problem is how can you do an input that
> makes the numbers strings? Or puts double quotes and a comma around a
number?

You've received a number of perfectly good suggestions so far, and they
illustrate nice and useful python programming techniques which you'll
benefit from learning. If you need to do this for production code though, I
suggest you look into Numerical python for handling large data arrays, and
you may want to use a convenient histogram builder from the Scientific
python family:  http://starship.python.net/crew/hinsen/ Konrad's code is
very good and well tested. With it, building a histogram for a large data
file is one line of code.

There's nothing wrong with your approach while you learn, I just wanted to
point you in the direction of production-quality resources for when you need
them.

Enjoy python!

f.





More information about the Python-list mailing list