No-brainer? Dictionary keys to variable name?
Greg Ewing
see_reply_address at something.invalid
Thu Aug 1 21:43:50 EDT 2002
Max M wrote:
> Christopher Myers wrote:
>
>> 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={}):
>
> def runSearchTest(self, **theDict):
Actually, I think what he wants to do is actually the other
way around -- he wants to be able to *call* it by passing
a dict and have the values in it end up in local variables.
If that's the case, leave the def statement the way
it is, and call it like this:
blarg.runSearchTest(**dictOfArgs)
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list