a couple of newbie questions
Joseph Paish
jpaish at freenet.edmonton.ab.ca
Fri Mar 21 10:15:12 EST 2003
i am in the process of converting a perl script to python and have a couple of questions :
---
1. is there a way to comment out a large block of code in python? the reason i ask is that i would
like to comment out the entire perl script and convert it piece by piece into python, uncommenting
each function as it is converted so i can test if it does what i want.
---
2. is there a way to read a datafile whose records are space separated so that the second field
becomes the key to a dictionary and the value portion is the entire record. for example,
01/01/2003 abc 1234.56 789.98 12332.98 <<< the original record
the key would be : abc
the value would be : 01/01/2003 abc 1234.56 789.98 12332.98
i have managed to read the datafile into a list of lists and would like to loop through this
collection of records and convert it to a list of dictionaries keyed on the second field. i have
already looked everywhere i can think of, but i haven't had any luck finding how to convert a list
of lists into dictionaries.
an alternative would be to bypass the list of lists altogether and populate the dictionary as i read
each record. this would be even simpler.
suggestions?
thanks
joe
More information about the Python-list
mailing list