Re: trying to grasp OO : newbie Q?

2006-04-13 Thread BartlebyScrivener
Pretty tough to beat Alan Gauld, but the more examples the merrier for me, and the infogami has plenty of those. Thanks. http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm rpd -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Kent Johnson
John Salerno wrote: > Couldn't we also say that this issue of namespace scope is a little more > specific to Python than OOP in general? I could very easily be wrong, > but I wouldn't want the poster to think that this is how OOP works always. No, the confusion in the OP was between class attrib

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread John Salerno
[EMAIL PROTECTED] wrote: > Thanks guys, > > It is starting to make much more sense. Most documentation I find about > OO is very academic Couldn't we also say that this issue of namespace scope is a little more specific to Python than OOP in general? I could very easily be wrong, but I wouldn't

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > It is starting to make much more sense. Most documentation I find about > OO is very academic you may find Jay Parlar's new python class tutorial helpful: http://parlar.infogami.com/pytut_classes_copy (this is a proposed addition/replacement for the class chapter

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread mitsura
Thanks guys, It is starting to make much more sense. Most documentation I find about OO is very academic -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Wildemar Wildenburger
J Rice wrote: > Someone should correct me if I'm wrong but: > If > you want to change myVar for the whole class, you need to reference it > as self.myVar. > wrong: If you want to change myVar for the whole *class*, you need to reference it as Obj.myVar (prefix with classname). self.myVar will c

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Ben C
On 2006-04-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I just started with Python and I am new to OO programming. > Here is a simple code: > " > class Obj: > myVar = 1 > > def __init__(self): > myVar = 2 > > # > > > myObj = Obj() > > print myObj.myVar > " >

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread J Rice
Someone should correct me if I'm wrong but: If you add "print myVar" to __init__, you will see that myVar is assigned to "2" in that function. It doesn't change the assignment of "1" in the class because myVar in __init__ is local to __init__. If you want to change myVar for the whole class, yo

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Azolex
[EMAIL PROTECTED] wrote: > Hi, > > I just started with Python and I am new to OO programming. > Here is a simple code: > " > class Obj: > myVar = 1 > > def __init__(self): > myVar = 2 > > # > > > myObj = Obj() > > print myObj.myVar > " > > The output is of this scri

trying to grasp OO : newbie Q?

2006-04-13 Thread mitsura
Hi, I just started with Python and I am new to OO programming. Here is a simple code: " class Obj: myVar = 1 def __init__(self): myVar = 2 # myObj = Obj() print myObj.myVar " The output is of this script is '1'. I would except it to be '2'. I not understanding