No-brainer? Dictionary keys to variable name?

Christopher Myers chris.myers at
Thu Aug 1 22:20:26 CEST 2002

I'm re-implementing some code that I wrote, and I don't want to rewrite
more than I have to.

Specifically, I'm looking for a way to take a dictionary, e.g.
{ "a" : 1, "b" : 2, "c" : 3 }

and convert it into something like

a = 1
b = 2
c = 3

so that the keys are the actual variable names and the values are
obviously the variables' values.

The reason I'm trying to do this is I have a method as follows:

    def runSearchTest(self, script_url, f_title="", leftquery="", 
                          findwords="titlestext", part="", 
                          categories="all", categval=(), 
                          topics="all", topicvalue=() ):

And I've changed my mind about the implementation.  I'd like to change
the parameters to 

    def runSearchTest(self, oneTest={}):

and have the method convert the dictionary to variables as I described

A quick googling didn't help me, so I was wondering if anyone in the
group could.

Thanks in advance!

Christopher Myers, Graduate Software Developer 
Ingenta, Inc.
12 Bassett St.
Providence, RI  02903
ph:  401.331.2014 x 102
em:  chris.myers at
aim: chrismyers001

More information about the Python-list mailing list