Kent Johnson wrote on 27.09.2005:

>Jan Eden wrote:

>>The problem is that the __init__ methods of the respective classes
>>take a different number of parameters - this is why I pass the
>>whole safe_parameters dictionary.
>
>I think if you pass the dictionary as keyword arguments rather than
>as a single dict you will get what you want.

>page =
>valid_types[safe_parameters['type']](**safe_parameters)
>
>This syntax means, use safe_parameters to populate the keyword
>arguments of the function. Any parameters which are not in
>safe_parameters will be set to their default values, and in other
>calls you can set the parameters as you like. Here is a simple
>example:

I see. I did not know that I can use a formal parameter **param in calls - 
thought I could only do so in function definitions:

def func(**param):
    ...
    
 func(id=1, stuff='blah')
 
 Thanks for that!
 
 Jan
-- 
Mac OS X. Because making Unix user-friendly is easier than debugging Windows.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to