works in trinket not webvpython

70 views
Skip to first unread message

Michael Burns-Kaurin

unread,
Nov 10, 2021, 11:16:46 PM11/10/21
to Glowscript Users
Is there a difference between 2.9 and 3.2 so that code working on trinket.io will give this error on glowscript.org:
SyntaxError: Function statements require a function name

Michael Burns-Kaurin

unread,
Nov 10, 2021, 11:47:47 PM11/10/21
to Glowscript Users
Oh, I get the same error on trinket using 3.1.

Bruce Sherwood

unread,
Nov 11, 2021, 1:06:11 AM11/11/21
to Glowscript Users
Please provide a SHORT program that demonstrates the bug, otherwise there's no way to explore the issue.

Bruce

Michael Burns-Kaurin

unread,
Nov 11, 2021, 8:32:26 AM11/11/21
to Glowscript Users
By gradually adding pieces, I think the culprit is this line:

for ball in (bal for bal in lightBalls if bal.flag):

Oddly, I think I can revise it using the filter function now that it works in 3.2 (but I suppose it won't work in trinket 3.1?).

Joe Heafner

unread,
Nov 11, 2021, 10:52:15 AM11/11/21
to glowscri...@googlegroups.com

On Nov 11, 2021, at 08:32, Michael Burns-Kaurin <burnsk...@gmail.com> wrote:

By gradually adding pieces, I think the culprit is this line:

for ball in (bal for bal in lightBalls if bal.flag):

Oddly, I think I can revise it using the filter function now that it works in 3.2 (but I suppose it won't work in trinket 3.1?).

Trinket lags behind updates because they must manually update their system manually and aren’t always aware of changes. I’ll put a bug in their ear.

Joe Heafner
Sent from my iPhone


Bruce Sherwood

unread,
Nov 11, 2021, 1:23:31 PM11/11/21
to Glowscript Users
You unfortunately don't provide a program that we can test, but it seems possible that the complexity of the statement "for ball in (bal for bal in lightBalls if bal.flag):" means that RapydScript (and/or Web VPython) might not handle this structure correctly in transpiling from Python to JavaScript.

Bruce

Michael Burns-Kaurin

unread,
Nov 11, 2021, 1:37:29 PM11/11/21
to Glowscript Users
That seems likely since I had a similar problem using lambda.  Here is a shortened program that works in 2.9 but fails in 3.1 and 3.2:

lightBalls = []
flag = True
for i in range(6):
    b = sphere(radius = i+1)
    b.flag = flag
    flag = not flag
    b.num = i
    print(i,b.flag,b.num)
    lightBalls.append(b)
for ball in (bal for bal in lightBalls if bal.flag):
    print(ball.num)

Bruce Sherwood

unread,
Nov 11, 2021, 11:19:55 PM11/11/21
to Glowscript Users
Your program now works correctly in Web VPython 3.2. Thanks for the clear report.

Bruce

Michael Burns-Kaurin

unread,
Nov 12, 2021, 9:23:03 AM11/12/21
to Glowscript Users
Thanks for your diligent hard work.  I guess not many have tried some of these python things in glowscript before.

Bruce Sherwood

unread,
Nov 12, 2021, 4:23:12 PM11/12/21
to Glowscript Users
Yes, recently there have been quite a few sophisticated users of VPython reporting bugs that have been present and unreported for years.

Bruce
Reply all
Reply to author
Forward
0 new messages