I think it’s preferable to use a dictionnary if it’s possible:
vars_dict = {}
vars_dict["my_variable"] = 'Some Value'
vars_dict["my_variable2"] = 'Some Value'
I think it’s more pythonic.
More Related Contents:
- Python NameError, variable ‘not defined’
- How to make python create variables, without the user creating the variables?
- Check if input is empty
- Getting the name of a variable as a string
- How to use a variable inside a regular expression?
- How do I check if a variable exists?
- Are Python variables pointers? Or else, what are they?
- What is the naming convention in Python for variable and function names?
- “Fire and forget” python async/await
- Viewing all defined variables [duplicate]
- Python list doesn’t reflect variable change
- How can you print a variable name in python? [duplicate]
- How to check if type of a variable is string?
- What is the difference between class and instance variables?
- python class instance variables and class variables
- Variable assignment and modification (in python) [duplicate]
- How can I print variable and string on same line in Python?
- Dynamic variable in Python [duplicate]
- Two values from one input in python?
- pyodbc – How to perform a select statement using a variable for a parameter
- Python objects confusion: a=b, modify b and a changes! [duplicate]
- “Asyncio Event Loop is Closed” when getting loop
- How do I import variable packages in Python like using variable variables ($$) in PHP?
- More elegant way of declaring multiple variables at the same time
- asyncio.ensure_future vs. BaseEventLoop.create_task vs. simple coroutine?
- How to set Python3.5.2 as default Python version on CentOS?
- How to disable password request for a Jupyter notebook session?
- How to share a variable between 2 threads
- Why does foo = filter(…) return a , not a list? [duplicate]
- using variable in import command