arguments with default values in function definitions

17 views
Skip to first unread message

Joe Heafner

unread,
Mar 3, 2015, 10:47:45 PM3/3/15
to GlowScript Users
I’m porting a library of VPython functions to GlowScript and have discovered that apparently I can’t use arguments with default values in function definitions. Look at the following program:

http://www.glowscript.org/#/user/heafnerj/folder/My_Programs/program/mandipy3


If I write MakeCoordAxesAt() it works. If I write MakeCoordAxesAt(ctr=vector(1,1,1)) I get a popup error message

TypeError: undefined is not a function
Line 51:
Called from line 71:

But I can write MakeCoordAxesAt(vector(1,1,1)) to get the desired behavior. An obvious problem is that now I can’t supply non-default values for arguments because I can’t name the arguments in a function call. I also can’t specify any value for any argument beyond the first.

Am I overlooking anything?

Joe Heafner
Sent from one of my Macs


Bruce Sherwood

unread,
Mar 4, 2015, 12:37:54 AM3/4/15
to glowscri...@googlegroups.com
Read the documentation on RapydScript at http://rapydscript.pyjeon.com/

I haven't fully internalized the differences from classic Python, but this is one of the areas where I think there are some differences.

Bruce Sherwood

unread,
Mar 4, 2015, 12:44:48 AM3/4/15
to glowscri...@googlegroups.com
Note for example this:

def f(a=5, b=3):
    print(a,b)

f() # 5, 3
f(13) # 13, 3
f(b=10) # <Object> 3


Reply all
Reply to author
Forward
0 new messages