[Tutor] Where's the Walrus?

Lindsay Davies Lindsay.Davies@moonshine.co.uk
Wed, 21 Feb 2001 08:02:59 +0000


Two small changes...

line 7    def next_personality(self):
                                ^^^^
and

line 23   ally_oop.next_personality()
                                    ^^
Best wishes,

Lindsay


On 20/2/01, Tim Johnson wrote about '[Tutor] Where's the Walrus?':
>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
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor