--- infidel <[EMAIL PROTECTED]> wrote: > # reading CSV files, tuple-unpacking > import csv > > #pacific.csv contains: > #1,CA,California > #2,AK,Alaska > #3,OR,Oregon > #4,WA,Washington > #5,HI,Hawaii > > reader = csv.reader(open('pacific.csv')) > for id, abbr, name in reader: > print '%s is abbreviated: "%s"' % (name, abbr) >
Definitely on track. I like that it uses a batteries-included module, and this program definitely reminds me of the type of smallish, but very useful, programs that I write in Python frequently on the job. I would add one more criterion to my challenge, though. You should be able to run the program simply by copying/pasting the code into a file and running Python. So I would change your program (as currently presented) to write its own input file for demonstration purposes. One more suggestion--maybe it could exercise a little more of the CVS module, i.e. have something in the data that would trip up the ','.split() approach? ____________________________________________________________________________________ Need a vacation? Get great deals to amazing places on Yahoo! Travel. http://travel.yahoo.com/ -- http://mail.python.org/mailman/listinfo/python-list