RPi Awesomeness RPi Awesomeness - 6 months ago 65
Python Question

How to execute Python code from within Visual Studio Code

Visual Studio Code was recently released and I liked the look of it and the features it offered, so I figured I would give it a go.

I downloaded the application from the downloads page
fired it up, messed around a bit with some of the features ... and then realized I had no idea how to actually execute any of my Python code!

I really like the look and feel/usability/features of Visual Studio Code, but I can't seem to find out how to run my Python code, a real killer because that's what I program primarily in.

Does anyone know if there is a way to execute Python code in Visual Studio Code?

Answer

You can add a custom task to do this. Here is a basic custom task for Python.

{
    "version": "0.1.0",
    "command": "c:\\Python34\\python",
    "args": ["app.py"],
    "problemMatcher": {
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*)+s$",
            "message": 1
        }
    }
}

You add this to tasks.json and press CTRL + SHIFT + B to run it.

Comments