Re: [Tutor] Re: Help with classes (Joseph Q.)

2005-04-09 Thread Kent Johnson
Joseph Quigley wrote: class Message: def init(self, p = 'Hello world'): self.text = p def sayIt(self): print self.text m = Message() m.init() m.sayIt() m.init('Hiya fred!') m.sayIt() This is OK but a more conventional usage is to write an __init__() method. This is sometimes called a

[Tutor] Re: Help with classes (Joseph Q.)

2005-04-09 Thread Andrei
Joseph Quigley wrote on Fri, 08 Apr 2005 16:46:33 -0600: > Now what are dictionaries and the __name__ really used for? A byte of > python never got that through my thick skull. Dictionaries associate a value with a certain key, sort of like a real world dictionary where you can take a word and l

[Tutor] Re: Help with classes (Joseph Q.)

2005-04-09 Thread Joseph Quigley
class Message: def init(self, p = 'Hello world'): self.text = p def sayIt(self): print self.text m = Message() m.init() m.sayIt() m.init('Hiya fred!') m.sayIt() > Well this OOP stuff is realy hard for me as I have never even > programmed it took me a while just to understand defs. Th

[Tutor] Re: Help with classes

2005-04-08 Thread Andrei
Kevin gmail.com> writes: > Well this OOP stuff is realy hard for me as I have never even > programmed it took me a while just to understand defs. However I am > determined to learn how to do it. My biggest problem is with __init__ > I still don't understand how to use it. Though I did try somthin

Re: [Tutor] Re: Help with classes

2005-04-08 Thread Alan Gauld
> Well this OOP stuff is realy hard for me as I have never even > programmed it took me a while just to understand defs. That's OK, OOP is quite a strange concept for many folks. Its actually easier to learn as a beginner than for folks who have been programming without OOP for a long time! > det

Re: [Tutor] Re: Help with classes

2005-04-08 Thread Kevin
Well this OOP stuff is realy hard for me as I have never even programmed it took me a while just to understand defs. However I am determined to learn how to do it. My biggest problem is with __init__ I still don't understand how to use it. Though I did try somthing different with my code rather the

[Tutor] Re: Help with classes

2005-04-08 Thread Andrei
Bob Gailer alum.rpi.edu> writes: > At 12:22 PM 4/7/2005, Andrei wrote: > >Kevin gmail.com> writes: > > > > > I am fooling around with classes and I was trying to create a very > > > small one player text adventure. I made a class called commands here > >I don't think you're making proper use of

Re: [Tutor] Re: Help with classes

2005-04-07 Thread Alan Gauld
> >I don't think you're making proper use of classes. > > IMHO there is no "proper use of classes". It depends on whether the OP wants to pursue OOP. There are many uses of classes that are not related to OOP. But if we are talking about good OOP practie then there are some uses of classes that ar

Re: [Tutor] Re: Help with classes

2005-04-07 Thread Bob Gailer
At 12:22 PM 4/7/2005, Andrei wrote: Kevin gmail.com> writes: > I am fooling around with classes and I was trying to create a very > small one player text adventure. I made a class called commands here > it is: > class Commands: > def __init__(self): > pass > def quiting(self): > 

[Tutor] Re: Help with classes

2005-04-07 Thread Andrei
Kevin gmail.com> writes: > I am fooling around with classes and I was trying to create a very > small one player text adventure. I made a class called commands here > it is: > class Commands: > def __init__(self): > pass > def quiting(self): > sys.exit() > I want to beab