[Tutor] Re: Program Questions
Andrei
project5 at redrival.net
Thu Jul 15 20:34:17 CEST 2004
mandy bowen wrote on Thu, 15 Jul 2004 17:25:11 +0000:
> It tells me for the line:
> a = Account(1000.00)
> this constructor takes no arguments.
Here's an interactive session demonstrating what you did wrong (assuming
that's the only error, I haven't read all your code):
>>> class Account(object):
... def __init__(self, val):
... print val
>>> a = Account(4)
4
>>> class Bccount(object):
... def _init_(self, val):
... print val
>>> b = Bccount(4)
Traceback (most recent call last):
File "<input>", line 1, in ?
TypeError: default __new__ takes no parameters
>>> b = Bccount()
>>> b._init_(4)
4
You've spelled __init__ incorrectly. It's got TWO underscores on each side,
but you've written a single one.
> It also says for all of the "print" lines following the class call in
> MenuOption that "print" is invalid syntax.
>>> print \n
And what is \n according to you? Right, it's nothing. \ is a line
continuation character, n would be a non-existant variable which is put
after a line continuation character - so you've got two errors. I presume
you want to print an empty line (or two, to be precise). You do that by
printing the *string* "\n":
>>> print "\n"
--
Yours,
Andrei
=====
Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
More information about the Tutor
mailing list