I have a string whose content is a function name, how to refer to the corresponding function in Python?

Since you are taking user input, the safest way is to define exactly what is valid input: dispatcher={‘add’:add} w=’add’ try: function=dispatcher[w] except KeyError: raise ValueError(‘invalid input’) If you want to evaluate strings like ‘add(3,4)’, you could use safe eval: eval(‘add(3,4)’,{‘__builtins__’:None},dispatcher) eval in general could be dangerous when applied to user input. The above is safer … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)