Create variables from strings in Python -
is following possible in python:
>>> vars = {'a': 5} >>> makevars(vars) >>> print 5
so, makevars converts dictionary variables. (what called in general?)
it's possible, sometimes, it's bad idea. in spite of name, variables themselves should not variable. they're part of code, part of logic. trying 'replace' local variables way makes code inefficient (since python has drop of optimizations), buggy (since can accidentally replace didn't expect), hard debug (since can't see what's going on) , plain unreadable. having 'dynamic values' dicts , lists , other containers for.
Comments
Post a Comment