[Tutor] functions and errors
dman
dman@dman.ddts.net
Wed, 22 May 2002 11:19:26 -0500
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, May 22, 2002 at 03:33:21PM +0000, Terje Johan Abrahamsen wrote:
| I am trying to write a program that does several different tasks in Excel=
.=20
| However, before I get there, I have to understand the basics. This is wha=
t=20
| I have written so far.
|=20
| class accountcurrents:
=2E..
| def finnxlpolicy():
^^
| print"world"
| Traceback (most recent call last):
| File "<interactive input>", line 1, in ?
| TypeError: unbound method finnxlpolicy() must be called with=20
| accountcurrents instance as first argument (got nothing instead)
Did you try to do
accountcurrents.finnxlpolicy()
? You can't do that because the method is not really a part of the
*class*, but rather a part of *instances of the class*.
| If I write n =3D accountcurrents(), n.finnxlpolicy() I get the following=
=20
| error:
That's the right way to use the class.
| Traceback (most recent call last):
| File "<interactive input>", line 1, in ?
| TypeError: finnxlpolicy() takes no arguments (1 given)
|=20
| What do I do wrong? Thanks in advance....
You forgot to include the instance in the parameter list of the
method. The corrected class is :
class accountcurrents:
#...
def finnxlpolicy( self ):
print"world"
-D
--=20
Microsoft is to operating systems & security ....
.... what McDonald's is to gourmet coo=
king
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
--envbJBWh7q8WU6mo
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
iEYEARECAAYFAjzrxQ4ACgkQO8l8XBKTpRTSwgCfSVy9nwXze/qP9oWzO3HhJSI/
/p4AnR7/0wrrbVhvmt6c3mrVtIJOwULC
=mp/s
-----END PGP SIGNATURE-----
--envbJBWh7q8WU6mo--