GlowScript 2.1 Features

38 views
Skip to first unread message

Adam Hausknecht

unread,
Sep 11, 2016, 7:27:47 PM9/11/16
to VPython-users
 Does GlowScript 2.1 vpython 

1. Support Python classes?

2. Support Python formatting statements such as either of the following or should I use JavaScript to do this?

outStr = "x = %5.2f"%(pi) or
outStr = "x = {:5.2f}".format(pi)

3. Have a true floating point rounding function or do I need to use JavaScript functions ?

In general I'm not clear as to what extent one can mix JavaScript and GlowScript 2.1!
Also, I am not clear as to what features of Python are supported!

Regards,

Adam Hausknecht

Bruce Sherwood

unread,
Sep 11, 2016, 8:51:31 PM9/11/16
to VPython-users
1. This program uses a class (near the top of the program):


However, I should say that argument passing is somewhat problematic. The only scheme I trust is simply using positional arguments, like this:

def f(x,y):
    return x+y

f(3,5)

Because the original RapydScript Python-to-JavaScript transpiler leaves much to be desired in its handling of classes and function arguments, I hope to replace it in the near future with rapydscript-ng, whose developer has been very active in making the transpiling ever closer to true Python.

2. GlowScript VPython does not support the older Python scheme that uses "%" but it does support the newer ".format" scheme. See this discussion (or Python documentation):


3. Yes, there is a round() function. See the following for a full listing of supported functions, most of which are imported from the JavaScript Math library:


4. The RapydScript transpiler is a rather thin wrapper around JavaScript, and for example you can include jQuery statements and even anonymous functions. See the following for details (and this link is on the first page of glowscript.org):


Adam Hausknecht

unread,
Sep 17, 2016, 10:05:42 PM9/17/16
to VPython-users
Thanks for your reply! 

    
Adam Hausknecht
 
Reply all
Reply to author
Forward
0 new messages