[Tutor] Where's the Walrus?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 20 Feb 2001 23:22:18 -0800 (PST)

On Tue, 20 Feb 2001, Tim Johnson wrote:

> 	def next_personality():
> 		print "next personality"
> 		if self.which < 4:
> 			self.which = self.which + 1
> 			print "next"
> 		else:
> 			self.which = 0
> 			print "first"

One other thing; even if next_personality() doesn't take in an argument,
since it's still a member function, you'll need to refer to a "self" as
its argument.

    def next_personality(self):

In C++, you might be familiar with the 'this' pointer.  It's the same
idea, but with Python, we explicitly show it as a parameter, just to
disambiguate things.