[Tutor] Where's the Walrus?
Tim Johnson
tim@johnsons-web.com
Tue, 20 Feb 2001 18:38:22 -0900
Hello:
I'm creating my first object.
I have a method to advance an index.
The method doesn't respond.
code is below:
#######################################################
class schiz:
def __init__(self):
self.moods = ["I'm a little teapot", "I am the Walrus",
"I hate broccoli", "I'm the Jolly Green Giant"]
self.which = 0
# my code doesn't even get called, or so it appears
def next_personality():
print "next personality"
if self.which < 4:
self.which = self.which + 1
print "next"
else:
self.which = 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 = 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
--
Tim Johnson
-----------
"Of all manifestations of power,
restraint impresses the most."
-Thucydides