variable name in python code example
Example 1: how to use a string variable as a variable name in python
name = 'varname'
value = 'something'
setattr(self, name, value)
print (self.varname)
Example 2: python variable
string = 'string'
integer = 5
boolean = True
Example 3: Use variables in python
x = 'Welcome'
print(x)
Example 4: python use variable name as variable
>>> foo = "bar"
>>> exec(foo + " = 'something else'")
>>> print bar
something else
>>>
Example 5: python how to write a variable
stringtext = 'lol'
stringtext2 = "xD"
integer = 2
float = 4.5
boolean = True