Closed zimmermant closed 5 years ago
Thanks for the report. In VPython 7 I get <class 'cyvector.vector'>, not what you get. What version of the vpython module are you using? What version of Python? I'm using vpython 7.5.0 with Python 3.7.
I've got VPython 7.5.0 with Python 3.6.8.
The GlowScript problem is an artifact of the RapydScript-NG Python-to-JavaScript transpiler, but I think I may be able to address the problem by supplying my own type() function.
I wouldn't expect a difference between Python 3.6.8 and Python 3.7. I'm running on Windows; what platform are you using?
Also, how do you launch the VPython 7 program? IDLE? Spyder? Jupyter notebook?
I've been testing my own replacement for type() and the only question left is this discrepancy between what you see for vec and what I see.
Also, could you tell me how you use the type() function? I would have thought that isinstance() would be more useful, and I've not used type() myself, as far as I can remember.
I'm running it on a Mac with macOS 10.14.4. I am running the command in a Jupyter notebook (ipython version 7.5.0 and jupyter-client version 5.2.4).
What I used was just
a=vector(1,2,3)
print(type(a))
I wanted to use isinstance()
but wasn't sure what string to enter for the class, so I was using the type()
command to try and figure that out.
I've updated GlowScript VPython so that the type() function now does useful things. I arbitrarily return the Windows form <class 'cyvector.vector'> rather than the Mac form <class 'vpython.cyvector.vector'>, but the key point is that the final term is "vector". For box (etc.) and int and float and sqrt and bool and list and dict and str I now return what you see in VPython 7. I wrote my own subroutine and redefined type() to point to my subroutine. Thanks much for you help.
Trying to find the type of a vector instance doesn't work in glowscript but does work in VPython. For example,
results in the following error in Glowscript 2.3 or later
In VPython this returns
<class 'vpython.cyvector.vector'>
, which is what I'd expect.