[Tutor] Re: Confounded again
Derrick 'dman' Hudson
dman@dman.ddts.net
Sat Nov 30 15:12:01 2002
--zYM0uCDKw75PZbzx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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:
|=20
| f(i=3D5)
|=20
| And this is true. But apparently within a class method you can!
| Does anyone know how this works?
You can call functions using "keyword arguments" regardless of whether
or not they are class methods.
http://python.org/doc/current/tut/node6.html#SECTION006720000000000000000
If you want to define a function that can accept any arbitrary keyword
argument use the "**" notation. For example :
def f( *args , **kwargs ) :
print "the position arguments are:"
print "-"*5
print args
print "-"*5
print "the keyword arguments are:"
print "-"*5
print kwargs
print "-"*5
-D
--=20
A)bort, R)etry, D)o it right this time
=20
http://dman.ddts.net/~dman/
--zYM0uCDKw75PZbzx
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj3pHtYACgkQO8l8XBKTpRSl0QCgrbeBdt9P9RPWiG1yUddOU1VR
7M0An1XI1VKrOqZ7Rzn4wa+S9xaTJzdf
=9i57
-----END PGP SIGNATURE-----
--zYM0uCDKw75PZbzx--