[Tutor] Confounded again

Rick Pasotto rickp@telocity.com
Sat Nov 30 14:53:02 2002


On Sat, Nov 30, 2002 at 07:09:28PM -0000, alan.gauld@bt.com wrote:
> I posted a reply saying you couldn't call a function like:
> 
> f(i=5)
> 
> And this is true. But apparently within a class method you can!
> Does anyone know how this works? Here is a session showing what 
> I did...
> 
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> def foo (i):
> ...   print i
> ...
> >>> foo(j = 7)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: foo() got an unexpected keyword argument 'j'
> 
> So that failed, as I expected.

Because you changed variable names.

-- 
If philanthropy is not voluntary, it destroys liberty and justice. The law
can give nothing that has not first been taken from its owner.
		-- Frederic Bastiat
    Rick Pasotto    rickp@telocity.com    http://www.niof.net