[Tutor] account class

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Sat, 22 Jul 2000 17:00:25 -0700 (PDT)


On Sat, 22 Jul 2000, Steven Gilmore wrote:
>   #prints a statement #
>      def  statement():
>           print balance

Class methods need to take 'self' as its first argument.  The reason's
because Python needs to know what 'balance' you mean --- you could make a
bunch of bank statements in your program, so statement() needs that
parameter.  When you say something like:

  a.statement()

Python will pass 'a' as the first parameter in statement.  This explains
the error message "TypeError: no arguments expected".

Good luck!