Need suggestion to speed up code...
Alex Martelli
aleaxit at yahoo.com
Fri May 11 05:00:20 EDT 2001
More information about the Python-list mailing list
Fri May 11 05:00:20 EDT 2001
- Previous message (by thread): Need suggestion to speed up code...
- Next message (by thread): Need suggestion to speed up code...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Emile van Sebille" <emile at fenx.com> wrote in message news:9dfjfk$ii9bk$1 at ID-11957.news.dfncis.de... > Except for the embedded tics ('), you could eval the string to get a tuple > of values, and perhaps some appropriate pre/post processing would take care > of those. Right, and the simplest preprocessing would be to change "''" into r"\'", I believe -- so no post-processing is actually needed. If the string being analyzed can contain backslashes, of course, things DO become more interesting again:-). You MIGHT first replace '\\' with '\\\\', then "''" with r"\'", I guess, but this is starting to get rather complicated... > >>> a = "(1, 'foo', 'bar', 34, 3.14159, 'an imbedded comma, this sting has', > 'this one isn''t so easy either')" > >>> b = a.replace("''","`") If here you did: b = a.replace("''", r"\'") > >>> eval(b) > (1, 'foo', 'bar', 34, 3.1415899999999999, 'an imbedded comma, this sting > has', 'this one isn`t so easy either') then the last item of the eval should have a ' rather than a `, as desired. Alex
- Previous message (by thread): Need suggestion to speed up code...
- Next message (by thread): Need suggestion to speed up code...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list