[Tutor] Where's the Walrus?
Chantier Thierry
chantier@esker.fr
Wed, 21 Feb 2001 10:01:30 +0100
Don't you have an error with 'one argument expected' or something like th=
at ?
I think your def next_personality(): should be def next_personality(self)=
:
I'm just a newbie but I had some problem like that this one I believe.
Thierry
Le mer, 21 f=E9v 2001, Tim Johnson a =E9crit :
> Hello:
> I'm creating my first object.
> I have a method to advance an index. =20
> The method doesn't respond.
> code is below:
> #######################################################
> class schiz:
> def __init__(self):
> self.moods =3D ["I'm a little teapot", "I am the Walrus",=20
> "I hate broccoli", "I'm the Jolly Green Giant"]=20
> self.which =3D 0
> # my code doesn't even get called, or so it appears
> def next_personality():
> print "next personality"
> if self.which < 4:
> self.which =3D self.which + 1
> print "next"
> else:
> self.which =3D 0
> print "first"
> def __str__(self):
> return self.moods[self.which]
> def __repr__(self):
> return self.moods[self.which]
> def __call__(self):
> return self.next_personality()
> ally_oop =3D schiz()
> print ally_oop
> ally_oop.next_personality
> print ally_oop
> #######################################################
> FYI: Am coming from a background in C++
> but please don't hold that against me :)
> TIA