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

Sander Sweers sander.sweers at gmail.com
Tue Jan 6 19:43:16 CET 2009


On Tue, Jan 6, 2009 at 09:46, Alan Gauld <alan.gauld at btinternet.com> 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 the tuple. You could even
> make it a class with the convertion fiunctions being methods.
> But whether the extra complexity is worthwhile will depend on
> what proportion of values get modified. If its a small proportion
> then the gain in speed from not doing the reverse convertion might
> be worth it. In most cases what you have done is probably the
> simplest approach and if its fast enough then don't worry about it!

This is too complex and the speed is good enough for 2000 lines in the
file. however...

I am doing this to learn about python and programming. So I am
interested how this class would look like. Could you give an example
or point me in the right direction how I can figure it out for myself?

Thanks
Sander


More information about the Tutor mailing list