Keyword calling gotcha ?

Moshe Zadka moshez at math.huji.ac.il
Wed May 26 01:04:58 EDT 1999


On 25 May 1999, Alex wrote:

> Yeah, I think the problem is that you're passing a dictionary rather
> than the same set of arguments to A.__init__.
> 
> >>> def keyword_usage_example (**parms):
>   	print parms
>   	keyword_usage_example (parms)
> 
> ... ... ... >>> 
> >>> keyword_usage_example (a=1,b=2) 
> {'b': 2, 'a': 1}
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> File "<stdin>", line 3, in keyword_usage_example
> TypeError: too many arguments; expected 0, got 1
> >>> 
> 
> There's probably a clean way to deal with this, but I don't know it.

Read up the documentation on the built-in apply function, which is 
good for just this usage (calling another function with the same
parameters) and many other.
--
Moshe Zadka <mzadka at geocities.com>. 
QOTD: My own exit is more likely to be horizontal then perpendicular.






More information about the Python-list mailing list