[Tutor] creating variables from the 'key' of a dictionary. (original) (raw)

Larry Blair lbblair at adaptisinc.com
Fri Jul 2 13:16:54 EDT 2004


I am really new to python and don't have much idea of the possibilities so this may be a stupid idea or I am thinking in the wrong direction.

We use a parameters file to drive different scripts. We have parameters like SOURCE_SERVER = 'cm05', TARGET_SERVER = 'ts02', SOURCE_USER = 'master', SOURCE_PSWD = 'password' etc. etc. For a specific set of servers we can use the same parameter file but extract different parameters specific for the script.

When we add a new parameter we have to open each script where it is used and declare the variable and extract the value from the parameters file.

I think what I want to do is create a function that would load a dictionary with all parameters from the file. Then in the original script use that dictionary in a for loop to create the variables from the key.

My question is there a way to create a variable with the name of the key in a dictionary i.e.

para = {} para['source_server'] = 'cm05'

at this point I want to create a variable with the name source_server and a value of 'cm05'.

Thanks Larry


Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is confidential privileged and/or exempt from disclosure under applicable law. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Thank you.



More information about the Tutor mailing list