Re: [Tutor] a class knowing its self

2006-01-21 Thread Ben Vinger
Yes, you are right, - Shuying Wang's suggestion fixed the immediate problem, but there is still someting wrong with my code - maybe I'll ask about it again later. --- Ewald Ertl <[EMAIL PROTECTED]> wrote: > > > Have a more precisely look at your code. > s.getName() does just return, what you h

Re: [Tutor] a class knowing its self

2006-01-19 Thread Ewald Ertl
Hi! Ben Vinger wrote: > Hello > > I've been reading about how a class has access to its > own 'self', so I tried the following, but it is not > working as I would expect: > > class Skill: >def __init__(self): > self.history = [] > >def setName(self, skill): > self.nam

Re: [Tutor] a class knowing its self

2006-01-18 Thread Shuying Wang
Ben, If you change example #b to: for s in SkillNames: skill = Skill() skill.setName(s) print skill.getName() You will find that the results are the same as #a. In your #b example, you are giving setName() the skill instance instead of the string you intended. --Shuying On 1/19/06, Be

[Tutor] a class knowing its self

2006-01-18 Thread Ben Vinger
Hello I've been reading about how a class has access to its own 'self', so I tried the following, but it is not working as I would expect: class Skill: def __init__(self): self.history = [] def setName(self, skill): self.name = skill def getName(self): return se