I want to find a list comprehension in python source code, for that I tried to use Pygments, but it didn't find the way to do that.
To be more specific, I want to do a function that recognize all the posible list comprehension. For example:
[x**2 for x in range(5)][x for x in vec if x >= 0][num for elem in vec for num in elem][str(round(pi, i)) for i in range(1, 6)]
This examples are obtained from https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions
It is also valid a solution with regular expression.
Thank you