python Dynamic Variable name
import Syscreatevar = locals () listtemp = range (1,10 for i in range (1 Span style= "color: #0000ff;" >print Sys.argv[i] A, b = Sys.argv[i].split ( = ) Createvar[a] = b print get= ", Get," put= ", put
It is worth noting that, with the python dynamic variable name This function, the external incoming parameters can not be the same as the variable name defined inside the code, otherwise it will cause the variable cross-read error, resulting in a code error and throw a variable can not read the exception, the reason is unknown, need to parse the source of Python underlying library
Workaround: Define extremely perverted variable names in Python code, and never enter them when external parameters are passed in.
Saltstack provides a range of methods internally, so just write a module,module with the following methods:
def Test (* *Kwargs) : param=kwargs['__pub_arg'][0] kw = for in param.items (): kw[d]=x return kw
Research on dynamic parametric names of Python and Saltstack