[Tutor] Trouble with classes - Pypeg again

bob bgailer at alum.rpi.edu
Mon Nov 21 19:45:16 CET 2005

At 08:52 PM 11/20/2005, ->Terry<- wrote:
>Hash: SHA1
>Ok, I've got my peg game roughed out and I'm having
>The error is:
>Traceback (most recent call last):
>    File "pypeg.py", line 113, in ?
>      main()
>    File "pypeg.py", line 107, in main
>      x.draw_board()                     # Refresh screen
>    File "pypeg.py", line 30, in draw_board
>      screen.blit(Peg.peg, (Peg.pegs[i]))  # Blit it.
>AttributeError: class Peg has no attribute 'peg'

screen.blit(Peg.peg, (Peg.pegs[i]))

Peg is the name of a class rather than an instance of a class.
Instances of Peg have the attribute peg. The class itself does not.
Without analyzing your code in detail I'm not sure of the fix, except 
to suggest you put an instance of Peg in place of Pe.

>The new code is at:
>I'm confused as to why. The whole OO picture
>has my head reeling, but I thought I had some
>grasp of the basics. Now I'm not so sure. d:^)
>Thanks much,
>- --
>      Terry
>"Be who you are and say what you feel, because those
>   who mind don't matter and those who matter don't mind."
>                                   -- Dr. Seuss
>Version: GnuPG v1.2.7 (GNU/Linux)
>Tutor maillist  -  Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051121/8fe27c30/attachment.htm

More information about the Tutor mailing list