[Tutor] Working with files, Truckers log

Kirby Urner urnerk@qwest.net
Fri, 05 Apr 2002 07:31:26 -0800


>
>Alternatively, as Kirby suggested you can write it as a
>python data structure and use the eval() function to
>recreate it.

Actually, I wasn't suggesting using eval().  I was
suggesting saving the string

v1 = [2,3,4.5,'fred',42]

instead of just

[2,3,4.5,'fred',42]

in the data.py file, and then accessing v1 as a module
variable after importing it (not opening it).

E.g.

   outfile = open('data.py','w')
   lineout = 'v1 = ' + str([2,3,4.5,'fred',42])
   outfile.write(lineout)
   outfile.close()

then:

   from data import v1

Kirby