Re: [Tutor] constructor

2010-04-04 Thread Alan Gauld
"Shurui Liu (Aaron Liu)" wrote Sorry, let me specify. I think comptuter will print out those two sentences like this: A new critter has been born! Hi. I'm an instance of class Critter. A new critter has been born! Hi. I'm an instance of class Critter. class Critter(object): """A virtual p

Re: [Tutor] constructor

2010-04-04 Thread Dave Angel
Shurui Liu (Aaron Liu) wrote: I am studying about how to create a constructor in a Python program, I don't really understand why the program print out "A new critter has been born!" and "Hi. I'm an instance of class Critter." twice. I guess is because "crit1 = Critter() crit2 = Critter()"

Re: [Tutor] constructor

2010-04-04 Thread Emile van Sebille
On 4/4/2010 11:11 AM Shurui Liu (Aaron Liu) said... Sorry, let me specify. I think comptuter will print out those two sentences like this: It's a little more interesting as you move forward from here. This is a small step... class Critter(object): """A virtual pet""" def __init__(s

Re: [Tutor] constructor

2010-04-04 Thread Lie Ryan
On 04/05/10 04:11, Shurui Liu (Aaron Liu) wrote: > But the result I got from computer is like this: > A new critter has been born! > A new critter has been born! > > Hi. I'm an instance of class Critter. > > Hi. I'm an instance of class Critter. Because you tell it to do it in that order: cr

Re: [Tutor] constructor

2010-04-04 Thread Shurui Liu (Aaron Liu)
Sorry, let me specify. I think comptuter will print out those two sentences like this: A new critter has been born! Hi. I'm an instance of class Critter. A new critter has been born! Hi. I'm an instance of class Critter. But the result I got from computer is like this: A new critter has be

[Tutor] constructor

2010-04-04 Thread Shurui Liu (Aaron Liu)
I am studying about how to create a constructor in a Python program, I don't really understand why the program print out "A new critter has been born!" and "Hi. I'm an instance of class Critter." twice. I guess is because "crit1 = Critter() crit2 = Critter()" But I don't understand how did co