0

I've installed and configured Pydev with Eclipse but when I try to use interactive shell I get errors. Can someone have a look and advise?

Code for two functions:

def convert_milage(t):  # t - number of miles per 1 gallon
    litersPer100Kilometers = 100/ ((t * 1.609) / 3.785) 
    return litersPer100Kilometers

def liters_needed(t, v): # t: distance in kms, v: fuel consumption
    fuelConsumption = convert_milage(v)
    litersNeeded = (t * fuelConsumption) / 100
    return litersNeeded

Error: http://i54.tinypic.com/2afmu7p.png

Error message:

>>> convert_milage(100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'convert_milage' is not defined
>>> 
1
  • Please add error descriptions into your question. Commented Aug 15, 2011 at 8:05

1 Answer 1

3

You need to open the console for the file you're in, not just use the general python console, as that knows nothing about the functions in your source file.

Press Ctrl-Alt-Enter and select Current active editor.

That should import the current module into your shell and make things work better.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.