View Full Version : Python Beginner OO programming help

September 29th, 2009, 12:11 AM
Well I got to the point in the book I'm learning from to get to OO programming and I'm spending more of my time getting IDLE to understand there graphics.py module that its based on than anything else.

This is the problem I'm on I thought it would be easier to see it before I edited the way needed. I'm getting errors like it doesn't recognize what graphics means and when I change from graphics import to import graphics. It doesn't understand what circle means. The book I'm learning from is python programing by john zelle its written alright getting the supplement material to actually work is the problem.

from graphics import *

def main():
win = GraphWin()
shape = Circle(Point(50,50), 20)
for i in range(10) :
dx = p.getX() - c.getX()
dy= p.getY() - c.getY()

Oh and I'm using Idle

September 29th, 2009, 01:56 AM
Have you installed the graphics module?

September 29th, 2009, 05:54 AM
Unrelated, but

from graphics import *

is bad practice, as it will pollute your namespace. Rather do

import graphics

and prepend all functions that belong to the graphics module with "graphics." (for example graphics.GraphWin() instead of GraphWin()).

September 29th, 2009, 10:07 PM
Have you installed the graphics module?

Install how? It worked before by just importing it the module is just one file called graphics.py
I became impatient dealing with this problem with there supplements and read ahead 2 chapters (functions and decision structures) Is there any 3rd party module I can download elsewhere that might be easier to install and get working? To go back and do the problems

September 30th, 2009, 11:10 AM
Moved to PT. ;)

September 30th, 2009, 06:40 PM
Have you placed graphics.py into the same directory where your code lies in?