[Tutor] Confounded again

Kalle Svensson kalle@lysator.liu.se
Sat Nov 30 15:08:01 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[alan.gauld@bt.com]
> I posted a reply saying you couldn't call a function like:
> 
> f(i=5)
> 
> And this is true.

No.

> 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'

>>> def foo(i):
...     print i
...
>>> foo(i=7)
7

Peace,
  Kalle
- -- 
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 <http://mailcrypt.sourceforge.net/>

iD8DBQE96RpydNeA1787sd0RAinpAJ9enS4/hoZDzKIf8qTpYz98vLc5HwCgw+wN
8VEtpZPhNyHywrSKsD8u4jU=
=Bh7h
-----END PGP SIGNATURE-----