There is a legacy code that I am looking into, there are many variables being used while importing excel sheet. Now I want to apply strip function to the variables if they are of type str and then could normally access them via their name.
I tried,like this
lvars = locals()
for k, v in lvars.items():
if(isinstance(lvars[k], str)):
lvars[k] = v.strip()
As far as I could research there is no way to update local variables in python by calling locals or any other means.
Is there a way to do so? I know I can use a dictionary to store the local vars and later access them via it but that would require a lot of update in the code too since I would like to access vars directly via their name.