Python: Parse string of bracketed list items into list of strings I have a string containing several items listed in the following notation:
myString = '[A][B][C]'

And I would like to parse that to a python list of several strings:
['A', 'B', 'C']

I know this can be solved with:
myString = myString.lstrip('[')
myString = myString.rstrip(']')
myList = myString.split('][')

I'd just like to know if there is an even more pythonic way of doing it.
Compare https://stackoverflow.com/a/1653143/10983441 where the most elegant way in the end was to use pyparsing with nestedExpr.
A Regex based solution
&gt;&gt;&gt; my_string_one
'[A][B][C]'
&gt;&gt;&gt; re.split(r&quot;\[([A-Z])\]&quot;, my_string_one)[1:-1:2]
['A', 'B', 'C']
&gt;&gt;&gt; my_string_two
'[A][B][C][D][E]'
&gt;&gt;&gt; re.split(r&quot;\[([A-Z])\]&quot;, my_string_two)[1:-1:2]
['A', 'B', 'C', 'D', 'E']

You can use re.split with the expression \[([A-Z])\ having a capture group for the uppercase letters. This is under the assumption that your strings always follow this pattern otherwise you may not get what you expect.