Re: [Edu-sig] Overloading (was Re: more on "variable names")
p.s. Here is a test to see if your students understand about binding, or if they are walking around with it confused with equality.
class Animal: ... def __init__(eyecolour, sound, action): ... self.eyecolour = eyecolour ... self.sound = sound ... self.action = action ... cat = Animal('green', 'miaux', 'pounce') dog = Animal('brown', 'woof', 'wag') vlerb = Animal('green', 'miaux', 'pounce')
Now go ask them if what they think vlerb == cat will print. This is an easier place to clear up the misunderstanding than the first time they start passing mutable objects as defaults to a function or a method, which is where my classes in the past have tended to blow up with this sort of misunderstanding. Laura
participants (1)
-
Laura Creighton