instance references?

bytecolor bytecolor at yahoo.com
Sun Jan 29 18:20:18 EST 2006


I'm working on a simple graphics package. I've got a function show()
that the user needs to call at the end of the script to actually
display the points, lines and circles that have been defined in the
script.

p1 = point(0, 0)
l1 = line(1, 3, -4, 5)
c1 = circle(-2, 3, 1)
show()

In each __init__() method of the point, line, and circle objects I add
self to a list in a separate module, then show() uses this list to
actually draw the objects. This works except:

l1 = line(point(1, 3), point(-4, 5))
c1 = circle(point(-2, 3), 1)

adds the references to the points used to define the objects to the
render list. I only want objects that have been assigned to a variable
to be rendered. (Try to ignore the function overloading.)

So how can I tell if an instance of point, line or circle has actually
been assigned to a variable?

-- 
bytecolor




More information about the Python-list mailing list