Helmut Jarausch <[EMAIL PROTECTED]> wrote:

> Chris Rebert wrote:
>> On Mon, Dec 1, 2008 at 1:01 PM, Helmut Jarausch <[EMAIL PROTECTED]>
>> wrote: 
>>> Hi,
>>>
>>> I am looking for an elegant way to solve the following problem:
>>>
>>> Within a function
>>>
>>> def Foo(**parms)
>>>
>>> I have a list of names, say  VList=['A','B','C1']
>>> and I like to generate abbreviation
>>> _A identical to parms['A']
>> 
>> Could you explain what you mean by that? Your sample code doesn't
>> seem to do any "abbreviation"...
>> Otherwise I don't see why you don't just have a proper parameter
>> list. 
> 
> In my application parms contains field names of an html form iff these
> fields have been modified.
> I'd like to use the short name  _A  instead of the longer expression
> parms['A'] 
> 
> 
You haven't yet explained why you don't just do:

def foo(A=None, **parms):
   ...

The code to call foo remains the same as before, but Python will unpack 
the named parameter into the local variable A for you automatically. Any 
other parms that you didn't know about in advance remain in the separate 
dictionary.


-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to