0

I'm having trouble running functions in Vpython.

I'm very new to this, I have a basic understanding of python, but I am experienced in other programming languages.

When I use Python's IDLE, I can save a function in a file named "test.py", hit F5, and run them in the command window. When I open VIDLE, I try to do the exact same thing, and it gives me the

Traceback (most recent call last):
  File "<pyshell#3>", line 1
    f(2)
NameError: name 'f' is not defined

error.

I'm running Python2, and I need to use vpython because the rendering window in the regular IDLE is very laggy and needs to have rate() called a bunch of times.

Any ideas? I've tried saving the file in the default directory that VIDLE lets me save, and also in the directory that IDLE is able to work from (i.e., if I put a function in said directory, IDLE can run it, but VIDLE can't).

EDIT:

The one I'm trying to run is the following:

from visual import *

def f(x):
    b = box(vector = (0, 0, 0), color=(1, 0, 0))
    b.rotate(angle = pi/4, axis=(1,0,0))
    b.pos
    b.pos +=vector(1,0,0)
user3475234
  • 1,503
  • 3
  • 22
  • 40

0 Answers0