Replacing string literals with u"..." (was Re: [I18n-sig] Literal strings)

Peter Funk
Fri, 2 Jun 2000 17:30:49 +0200 (MEST)


> > If code can be modified automatically (and what you proposed can
> > be done with a only slightly more elaborated operation than a simple
> > 's/"/u"/g' replacement) this is IMO no argument.

[Christian Tanzer]:
> Unfortunately, it's not that simple:
[...example of complicated string not repeated...]
> Do you really have `a only slightly more elaborated operation'? If so,
> please post it.

No, sorry.  

Indeed regular expressions seem not to be the right tool to
do this.  But since the module 'tokenize' from standard library
is able to identify all those forms of Python string literals, it
should be possible and not to hard to write a script, which will
identify all string tokens using 'tokenize' and replace them 
with u<token>.

Regards, Peter
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)