[Tutor] Trouble with classes - Pypeg again
bgailer at alum.rpi.edu
Mon Nov 21 19:45:16 CET 2005
At 08:52 PM 11/20/2005, ->Terry<- wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>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 ?
> 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'
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:^)
>"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
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.7 (GNU/Linux)
>-----END PGP SIGNATURE-----
>Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor