You can use exec
for that:
>>> foo = "bar"
>>> exec(foo + " = 'something else'")
>>> print bar
something else
>>>
More Related Contents:
- unindent does not match any outer indentation level python3.6.4 [duplicate]
- Importing Tweets via Python using Tweepy
- How to select random key with common values?
- max() functions with string argument
- What is the meaning of single and double underscore before an object name?
- All combinations of a list of lists
- String formatting in Python
- A faster strptime?
- setup script exited with error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
- Read specific columns from a csv file with csv module?
- Why doesn’t exec work in a function with a subfunction?
- Preprocessing in scikit learn – single sample – Depreciation warning
- pandas read_csv and filter columns with usecols
- Splitting a string by list of indices
- Python Flask Intentional Empty Response
- Is there a way to preserve duplicate keys in python dictionary [duplicate]
- Delete a subplot
- How to change outliers to some other colors in a scatter plot
- Append a dictionary to a dictionary [duplicate]
- Python time measure function
- How to fix “no module named ‘app_one'”
- What is the purpose of static methods? How do I know when to use one? [duplicate]
- Pandas query function not working with spaces in column names
- How to update an existing Conda environment with a .yml file
- python strptime format with optional bits
- TypeError: list indices must be integers or slices, not list
- Python: powerset of a given set with generators [duplicate]
- Limit Python VM memory
- Python: type-hinting a classmethod that returns an instance of the class, for a class that is inherited
- list comprehension with multiple conditions (python)