Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

sage terms not defined on import

I made a small routine for Sagemath 9.1 to show the most well-defined colors (with names) for my monitor. Works fine. But when I make it into a module then import it into Sagemath, the program chokes on terms which are defined in sagemath, such as "var" and "point". I even tried importing sage from the __init__.py program, but no luck. What's going wrong?

def colorlist():
    colors = ['red', 'green', 'blue', 'black', 'orange', 'purple', 'cyan', 'magenta', 'lime', 'pink', 'teal', 
              'brown', 'maroon', 'olive', 'navy', 'grey']
    var('x y')
    point_list = []
    name_list = []
    text_list= []
    x = 0; y = 0
    for color in colors:
        x+=1;y+=1
        name_list.append(color)
        point_list.append(point((x,y), rgbcolor=color,size=50))
        text_list.append(text(color,(x,y), color="black"))

    new_list = point_list + text_list
    return sum(new_list)  

ERROR
/opt/sagemath-9.1/local/lib/python3.7/site-packages/colors/showcolors.py in showthem()
      9         x+=1;y+=1
     10         name_list.append(color)
---> 11         point_list.append(point((x,y), rgbcolor=color,size=50))
     12         text_list.append(text(color,(x,y), color="black"))
     13 

NameError: name 'point' is not defined