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

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -