Snippets tagged “getattr”
2 snippets use this tag.
- Calling a function of a module by using its name (a string)Python
To call a function from a module by using its name as a string, you can use the importlib module.
- How do I check if an object has an attribute?Python
You can use the hasattr function to check if an object has an attribute.