Re: [Tutor] exercise with classes 2nd attempt

2012-02-12 Thread Brian van den Broek
On 12 Feb 2012 05:23, "Tonu Mikk" wrote: > > I am learning Python using the "Learn Python the Hard Way" book by Zed Shaw. I reached exercise 42 where we learn about Python classes. The exercise shows a game with one class that includes all the definitions for playing the game. For extra credit

[Tutor] exercise with classes 2nd attempt

2012-02-11 Thread Tonu Mikk
I am learning Python using the "Learn Python the Hard Way" book by Zed Shaw. I reached exercise 42 where we learn about Python classes. The exercise shows a game with one class that includes all the definitions fo

Re: [Tutor] exercise with classes

2012-02-09 Thread Joel Goldstick
On Thu, Feb 9, 2012 at 2:23 PM, Tonu Mikk wrote: > > > On Mon, Feb 6, 2012 at 12:58 PM, Dave Angel wrote: >> >> On 02/06/2012 01:24 PM, Tonu Mikk wrote: >>> >>> Now I get an error:  NameError: global name 'self' is not define. >>> >>> Tonu >>> >>> >> Put your remarks after the stuff you quote.  Y

Re: [Tutor] exercise with classes

2012-02-09 Thread Dave Angel
On 02/09/2012 02:23 PM, Tonu Mikk wrote: On Mon, Feb 6, 2012 at 12:58 PM, Dave Angel wrote: On 02/06/2012 01:24 PM, Tonu Mikk wrote: Now I get an error: NameError: global name 'self' is not define. Tonu Put your remarks after the stuff you quote. You're top-posting, which makes the r

Re: [Tutor] exercise with classes

2012-02-09 Thread Tonu Mikk
On Mon, Feb 6, 2012 at 12:58 PM, Dave Angel wrote: > On 02/06/2012 01:24 PM, Tonu Mikk wrote: > >> Now I get an error: NameError: global name 'self' is not define. >> >> Tonu >> >> >> Put your remarks after the stuff you quote. You're top-posting, which > makes the reply difficult to follow. >

Re: [Tutor] exercise with classes

2012-02-06 Thread Dave Angel
On 02/06/2012 01:24 PM, Tonu Mikk wrote: Now I get an error: NameError: global name 'self' is not define. Tonu Put your remarks after the stuff you quote. You're top-posting, which makes the reply difficult to follow. Use copy/paste to describe an error message. You retyped the one above

Re: [Tutor] exercise with classes

2012-02-06 Thread Tonu Mikk
Now I get an error: NameError: global name 'self' is not define. Tonu On Mon, Feb 6, 2012 at 10:19 AM, Nate Lastname wrote: > Hey Tonu, > > The problem is that in your statement definition, you are not > including the self argument. Your definition needs to be something > like: > def dolt(sel

Re: [Tutor] exercise with classes

2012-02-06 Thread Alan Gauld
On 06/02/12 16:12, Tonu Mikk wrote: Alan, thanks for explaining about passing objects to classes. This is an important concept for me to understand. I tried running the code, but run into an error that I could not resolve: TypeError: doIt() takes no arguments (1 given). Sorry the code was on

Re: [Tutor] exercise with classes

2012-02-06 Thread Nate Lastname
Hey Tonu, The problem is that in your statement definition, you are not including the self argument. Your definition needs to be something like: def dolt(self): # Do stuff. For more info on the self keyword, see http://docs.python.org/tutorial/classes.html, section 9.3.2. On 2/6/12, Tonu Mikk

Re: [Tutor] exercise with classes

2012-02-06 Thread Tonu Mikk
Alan, thanks for explaining about passing objects to classes. This is an important concept for me to understand. I tried running the code, but run into an error that I could not resolve: TypeError: doIt() takes no arguments (1 given). Tonu On Thu, Feb 2, 2012 at 7:09 PM, Alan Gauld wrote: > O

Re: [Tutor] exercise with classes

2012-02-02 Thread Alan Gauld
On 02/02/12 17:36, Tonu Mikk wrote: So far I have searched for info on how to pass variables from one class to another and have been able to create a small two class program (attached). But I seem unable to generalize from here and apply this to the game exercise. What would you suggest for m

Re: [Tutor] exercise with classes

2012-02-02 Thread Alexander Etter
On Feb 2, 2012, at 12:36, Tonu Mikk wrote: > I feel stumped and don't know how to go about creating this game with two > classes. > > So far I have searched for info on how to pass variables from one class to > another and have been able to create a small two class program (attached). > Tha

Re: [Tutor] exercise with classes

2012-02-02 Thread Prasad, Ramit
>I am learning Python using the "Learn Python the Hard Way" book by Zed Shaw. >I reached exercise 42 where we learn about Python classes. The exercise shows >a game with one class that includes all the definitions for playing the game. >For extra credit we are asked to create another version

[Tutor] exercise with classes

2012-02-02 Thread Tonu Mikk
I am learning Python using the "Learn Python the Hard Way" book by Zed Shaw. I reached exercise 42 where we learn about Python classes. The exercise shows a game with one class that includes all the definitions fo