Python (spyder) - name 'debugfile' is not defined
Question: I'm a beginner at programming and I need to do it for a university course. The
programme I'm using is Spyder (downloaded last night) and I have to code in
'python'. I've downloaded the version required, but I can't seem to run a
simple code.

    
    
    # -*- coding: utf-8 -*-
    """
    Spyder Editor
    
    This is a temporary script file.
    """
    
    import math
    
    def circleAreaFromDiameter(d):
        """takes a float d and returns the area of a cirlce with diameter d.
        """
        Area = math.pi * d**2/4.0
        return Area
    
    print circleAreaFromDiameter(1)
    

The last line, "print circleAreaFromDiameter(1)" has an exclamation mark at
the side of it saying that it's an invalid syntax. I don't understand why, but
I don't think that's my problem.

When I press the "run file" or "debug file", it says:

Traceback (most recent call last): File "", line 1, in NameError: name
'runfile' is not defined

or

Traceback (most recent call last): File "", line 1, in NameError: name
'debugfile' is not defined

I would really appreciate any help.


Answer: Clean up your line breaks, and I think it should run fine. It owrks for me in
this form:

    
    
    import math
    
    def circleAreaFromDiameter(d):
        """takes a float d and returns the area of a cirlce with diameter d. """
        area = math.pi * d**2/4.0
        return area
    
    print circleAreaFromDiameter(1)
    

The problem was pasting the Area assignment on the same line with the block
quote (triple-quoted string).

