Error with curve

3 views
Skip to first unread message

HWGNY

unread,
Dec 17, 2025, 11:11:42 AM (yesterday) Dec 17
to VPython-users
This simple program  throws the error:  IndexError: tuple index out of range in installed Python but  works fine in Glowscript.
Error thrown in
- Python  3.11.3
- Spyder with vpython

from vpython import curve, vec
curve(pos=(vec(0,0,0),vec(1,1,0)))

The traceback follows:

    curve(pos=(vec(0,0,0),vec(1,1,0)))

  File C:\Program Files\Python311\Lib\site-packages\vpython\vpython.py:2037 in __init__
    self.append(tpos)

  File C:\Program Files\Python311\Lib\site-packages\vpython\vpython.py:1893 in append
    pts, cps = self.process_args(*args1, **args)

  File C:\Program Files\Python311\Lib\site-packages\vpython\vpython.py:1833 in process_args
    tpos = self.parse_pos(args1[0])

  File C:\Program Files\Python311\Lib\site-packages\vpython\vpython.py:1878 in parse_pos
    v = list_to_vec(v)

  File C:\Program Files\Python311\Lib\site-packages\vpython\vpython.py:185 in list_to_vec
    return vector(L[0], L[1], L[2])

IndexError: tuple index out of range

Bruce Sherwood

unread,
Dec 17, 2025, 4:45:26 PM (yesterday) Dec 17
to VPython-users
This works with installed Python: curve(pos=[vec(0,0,0),vec(1,1,0)])

The reason why curve(pos=(vec(0,0,0),vec(1,1,0))) works in Web VPython is that Web VPython is transpiled to JavaScript, which apparently treats () and [] alike.

Bruce

Reply all
Reply to author
Forward
0 new messages