[Tutor] assigning types(?) to list elements

Jeff Shannon jeff@ccvcorp.com
Mon, 14 Oct 2002 13:07:25 -0700


Joseph Paish wrote:

> i guess i am asking if there is another way to make each of the variables the
> correct type without doing it one variable at a time the way it is now.

If you have control over the data file, you may want to consider reading and
writing it in binary format using the struct module.  That will let you create a
string specifying a sequence of types that will be used for each record (line).
See the docs on struct for more info, and then come back here with specific
questions.

If you're getting the data file from somewhere else, and can't control its
format, then your options are a little weaker.  Best bet then (provided that each
line is known to be the same) is probably to apply a list of types, as suggested
by previous respondents.

Jeff Shannon
Technician/Programmer
Credit International