2

What is the best Pythonic way to convert:

"[u'absolute_path_to_file1', u'absolute_path_to_file2']"

Which is of type str, notice the space after each comma, to:

['absolute_path_to_file1','absolute_path_to_file1']

I ended up with bunch of strip() and split() which is not pretty at all.

To clarify: another program is writing a list of absolute paths to disk (as a value of a key in a section created by ConfigParser). I have the ability to either adapt the generating script and/or the script reading back the values.

I found similar question, however, the input was not a plain string.

RisingSun
  • 2,137
  • 2
  • 14
  • 10

0 Answers0