Optimization help needed: Search and Replace using dictionary of parameters

Pekka Niiranen krissepu at vip.fi
Mon Dec 31 12:20:36 EST 2001


How can I do this most efficiently:

    I have filenames and parameters in a sparse matrix that is a
dictionary:

    {'file1, parameter1': xxx, 'file1, parameter2' : yyy,
    'file2, parameter1' : zzz, 'file2, parameter2': hhh, 'file2,
parameter3': ggg,
    'file3, parameter1': ccc,
    'file4, parameter1:' ddd, 'file4, parameter2:', eee}

    I would like to run search and replace to files for each parameters;

    For example: parameter1 in file1 should be replaced with xxx etc.

    Before I start writing code, any ideas what is the fastest way of
doing it ?:
        regex- or string -functions ? Map or readlines() ?

    Any ideas are appreciated..

-pekka-




More information about the Python-list mailing list