"Alan Gauld" <[email protected]> wrote
class Item(object):
def __init__(self, aFile):
data = aFile.readline().strip().split(:)
setattr(self, data[0], data[1])
The last two lines should of course be repeated 3 times...
Either in a loop or - for just 3 items - maybe hard coded...
items = []
f = open('myfile.txt')
while f: # stop when file is empty
items.append( Item(f) ) # process 3 lines
I also should have added that you need some exception
handling in case the dta doesn't fit cleanly... but I did say
it was pseudo code :-)
Alan G
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor