'Robot framework: how to get a list from a python method that returns a list

I am trying to get a list from the following python method through robot framework:

folders.py:
MAINFOLDERS = []
def get_locators():
    return MAINFOLDERS

and the keyword:

Assert main folders are in the same order
    ${MAINFOLDERS}=  folders.get_locators

As far as I understand, ${MAINFOLDERS} should be a list that looks like this:

[
'//span[contains(text(), "AutomationTestFolder - 02 18 2022 12:54:02")]', 
'//span[contains(text(), "AutomationTestFolder - 02 18 2022 12:54:05")]'
]

The problem is that the output is given as string, not a list. So the actual output is "['//span[contains(text(), "AutomationTestFolder - 02 18 2022 12:54:02")]','//span[contains(text(),"AutomationTestFolder - 02 18 2022 12:54:05")]']"

How can I create a list out of the output of folder.get_locators()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source