Pythonで変数文字列を使用して変数にアクセスする方法はありますか? たとえばeval
、次のように使用するよりもきちんとした方法が必要です。
def toggleListButtons (self):
buttons = ["flip", "remove", "removeAll", "delete", "deleteAll", "loadDirectory"]
for button in buttons:
eval("self." + button + "Button.setEnabled(!self." + button + "Button.isEnabled())")