Reserved keyword "display"

22 views
Skip to first unread message

Harlan Gilbert

unread,
Apr 21, 2022, 8:56:22 AM4/21/22
to Glowscript Users
Dear Bruce,

There is no action or response particularly needed on this, but I just discovered that display is effectively a reserved keyword, and that redefining this (e.g. making it a user-defined function) does very strange things.

Web VPython 3.2
def display(entry, i):
    pass
for n in range(20):
    display(1,-1)

Gives
TypeError: right-hand side of 'in' should be an object, got number

Weird!

Very best regards,
Harlan

Bruce Sherwood

unread,
Apr 21, 2022, 8:06:30 PM4/21/22
to Glowscript Users
Sorry about that. Historical VPython called what we now call a "canvas" a "display", so to make it a bit easier to move from old VPython to new we define display = canvas. Whenever we go to Web VPython 3.3 that archaic statement should be removed.

By the way, a reason for changing from display to canvas was that "display" has a crucial role in the Jupyter notebook environment.

Bruce
Reply all
Reply to author
Forward
0 new messages