Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread ALAN GAULD
> > If you always convert the values back to strings then you could > > just hold onto the original strings by storing them in a (str, val) tuple. > > If you do calculations and modify anmy of them then convert the > > value/string there and then and modify the tuple. You could even > > make it a

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread bob gailer
Sander Sweers wrote: On Tue, Jan 6, 2009 at 04:38, bob gailer wrote: I also suggest splitting convertValue into two functions, one that takes strings and one that takes numbers. A lot easier to read and maintain. FWIW you could dispense with reverse in convertValue by testing the

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread Sander Sweers
On Tue, Jan 6, 2009 at 09:46, Alan Gauld wrote: > If you always convert the values back to strings then you could > just hold onto the original strings by storing them in a (str, val) tuple. > If you do calculations and modify anmy of them then convert the > value/string there and then and modify

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread Sander Sweers
On Tue, Jan 6, 2009 at 04:38, bob gailer wrote: > I also suggest splitting convertValue into two functions, one that takes > strings and one that takes numbers. A lot easier to read and maintain. > > FWIW you could dispense with reverse in convertValue by testing the type of > value for int or str

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-06 Thread Alan Gauld
"Sander Sweers" wrote I use the csv module to read and write a csv file. When I read the file into a new list I convert the ints and the dates to int and time When writing the lines back to a csv file I loop over the lists and convert the values back with the same function but in reverse

Re: [Tutor] Convert values in a list back and forth from ints and time

2009-01-05 Thread bob gailer
Sander Sweers wrote: Hello Tutors, I use the csv module to read and write a csv file. When I read the file into a new list I convert the ints and the dates to int and time objects so I can do calculations. I use the below function which works. def convertValue(value, dateformat, reverse=False):

[Tutor] Convert values in a list back and forth from ints and time

2009-01-05 Thread Sander Sweers
Hello Tutors, I use the csv module to read and write a csv file. When I read the file into a new list I convert the ints and the dates to int and time objects so I can do calculations. I use the below function which works. def convertValue(value, dateformat, reverse=False): if reverse: