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
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
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
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
> 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
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
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
> >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
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):
>
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
10 matches
Mail list logo