thanks Ofer
def fn(**kwargs):
name = kwargs.get('name', kwargs.get('n', 'defaultname'))
data = kwargs.get('data', kwargs.get('d', 'defaultdata'))
> def fn(**kwargs): name = kwargs.get('name', kwargs.get('n')) # try
> 'name',
> default to -> try 'n', default to -> (None)
> name = kwargs.get('data', kwargs.get('d'))
>
> On Fri, Feb 6, 2009 at 12:50 AM, <[email protected]> wrote:
>
>>
>> i put this together to save on typing, hope it helps people
>> (saves on lots of typing)
>>
>> def myProc(**args):
>> usrName = parseArgs(args, 'name', 'n', 'test')
>> usrData = parseArgs(args, 'data', 'd', 'testB')
>> print usrName
>> print usrData
>>
>> def parseArgs(args, a, b, default):
>> for i in args:
>> if i == a or i == b:
>> default = args[i]
>> return default
>>
>> example
>> myProc(n = 'not default')
>>
>> thanks again nicolas for the insight
>>
>> >
>> > oups perhaps you must use:
>> > ... **keys.keys()
>> > as the ** collect all the undefind args in the procedure call in a
>> dict...
>> >
>> > >
>> >
>>
>>
>>
>> >
>>
>
>
> --
>
>
> - Ofer
> www.mrbroken.com
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---