I have a list of methods that i wish to apply on a list of objects. The objects contain info that will change the outcome of the methods. I will then store the objects that got an outcome that i want.
The code looks as the following: where chefs is the objects that should carry out an action on an ingredient.
I am getting this error AttributeError: 'Chef' object has no attribute 'possibleAction'
It seems like the compiler does not take the value from possibleAction (which i want) and instead just take the name of the variabel.
I am not sure if this is possible but i know that you can store function in variabels and then call them, so then this maybe works on methods too i thought. Anyway i am appriacting all the help i can get, cheers :)
possibleStates = []
for chef in state.getChefs():
for possibleAction in getAllPossibleActionForChef():
for ingredient in state.getKitchen().getIngredients():
newPossibleState = copy.copy(state)
if chef.possibleAction(ingredient): # Do doAction on state, if true save else trow away
possibleStates.append(newPossibleState)
return possibleStates