How to eliminate quotes around string field written to a file.

len lsumnler at gmail.com
Fri Nov 14 23:39:53 EST 2008


hi

Have this code in my program;

    filename = 'custfile'
    codeline = filename + ' = [\n'
    output.write(codeline)

record written to file look like this

     "custfile" = [

Yet in another part of the program I have code:

     def fmtline(fieldline):
         code = '(' + fieldline[1].replace('-', '_').replace('.',
'').lower() + \
          ', ' + fieldline[3] + '),\n'
          return code
       ...
     output.write(fmtline(wrkline))

fieldline is a list of which the first item in the list is a fieldname

record written to file looks like this, no quotes

    (customer_no, X(6).),
    (customer_name, X(30).),
    (customer_street_1, X(30).),
    (customer_street_2, X(30).),
    (customer_city, X(15).),

Why quotes  in the first case and not the second and how do I get read
of the quotes
in the first case.

Thanks
Len Sumnle



More information about the Python-list mailing list