I am working on migrating an old Python code base to Python3.
There are many strings which have the "u" prefix. Example u'Umlaut üöö'
Is there an automated way to remove the leading "u"?
A simple regex is does not work:
u'schibu': u' at the end must not get removed.
Example2:
Multiline: '''foo
schibu'''
Is there maybe a way which works without a regex, but via parsing the python syntax?
Update
My code needs to be compatible with Python2 and Python3 for some months.
The files already contain from __future__ import unicode_literals
Using 2to3 tool
unicodefixer should do that.Dry run with sample
spam.pyfilein shell:
output
EDIT: Note, you can run just a single fixer as shown above (in a dry run) and it will apply only the respective change.