Snippets tagged “vars”
3 snippets use this tag.
- How do I check if a variable exists?Python
In Python, you can check if a variable exists by using the globals() or locals() function to check if the variable is in the global or local namespace, respectively.
- Is there a built-in function to print all the current properties and values of an object?Python
In Python, you can use the built-in function vars() to print the properties and values of an object.
- List attributes of an objectPython
In Python, you can use the built-in function dir() to list the attributes of an object.