Re: reading a column from a file

2006-05-08 Thread pyGuy
f = open("datafile.txt", "r") data = [line.split('\t') for line in f] f.close() pressure = [float(d[1]) for d in data] temp = [float(d[2]) for d in data] --- This will parse the file into a matrix stored in 'data'. The last two lines simply iterate t

Re: Best way to emulate ordered dictionary (like in PHP)?

2006-04-12 Thread pyGuy
Great, that recipe is exactly what I needed, and much cleaner than my clumsy attempts. Thank you for your help. -- http://mail.python.org/mailman/listinfo/python-list

Best way to emulate ordered dictionary (like in PHP)?

2006-04-11 Thread pyGuy
I am dealing with user profiles, which are simply a set of field-value pairs. I've tried to many things to list, but for one, I tried creating a wrapper class which inherits the dictionary and overrides the iterator. Unfortunately I don't understand iterators enough to get this working and before I

Best way to emulate ordered dictionary (like in PHP)?

2006-04-11 Thread pyGuy
I am dealing with user profiles, which are simply a set of field-value pairs. I've tried to many things to list, but for one, I tried creating a wrapper class which inherits the dictionary and overrides the iterator. Unfortunately I don't understand iterators enough to get this working and before I

Binary tree problem (searching)

2006-04-04 Thread pyguy
Hi all, I am running into a conceptual glitch in implementing a simple binary tree class. My insertion and printing (sorting) seems to be ok, but when I search the tree, my find method isn't doing what I thought it should. Here is the output of running my tests: >python -i trees.py ***