I have a python file for example Animals.py, inside I defined 3 different classes like that:
#Animals.py
class Animal:
    listAnimal=["dog","cat"] #<------------
    def __init__(self):
        #Animal constructor
        pass
class Dog(Animal):
    def __ini__(self):
        #dog constructor
        pass
class Cat(Animal):
    def __ini__(self):
        #cat constructor
        pass
I would like to get access to the class variable listAnimal
I am not an expert of RF I tried to use that:
Import Library   Animal
${ListAnimal}   Animal.listAnimal
could you give some suggestion on that please?
You can use the Get Library Instance keyword from the BuiltIn library to get the currently active instance of the specified test library. Then you can use the Extended variable syntax to access the list and its elements.
Example:
${lib}=     Get Library Instance    Animal
Log     ${lib.listAnimal[0]}    # should log 'dog'
Log     ${lib.listAnimal[1]}    # should log 'cat'
${ListAnimal}=    Set Variable   ${lib.listAnimal}
                        I added a new function to the file Animals.py
def getListAnimals():
    return Animal.listAnimal
And I am now only using this function in the robot framework:
Import Library   Animals.py
${ListAnimal}   Get List Animals
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With