Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

798
Vistas
Python with Visual Studio Code - Run specific file

I am writing a small application with Visual Studio Code and Python. My application have these files:

Main.py
MyCustomClass.py

Basically, the Main.py is the entry point to the application. The other class is just logic to solve some problems.

While I developing the code, I test it, by running it, step by step. I run the application with F5 which is running the current file I'm editing. It can be the file MyCustomClass.py which doesn't have an entry point at all and I'm losing time to swap between files.

Is it possible to configure Visual Studio Code to run a specific file (Main.py) while running (F5)? No matter which file I am currently viewing.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You need to edit your launch.json file. A quick way to do it is to click the wrench icon on the run toolbar:

Enter image description here


Then add the following to the launch.json file:

    {
        "name": "Python: main.py (Integrated Terminal)",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/main.py",
        "console": "integratedTerminal"
    },

Above is my configuration, and the "program" line is what does the magic.

over 4 years ago · Santiago Trujillo Denunciar

0

The program setting in your launch configuration settings refers to the Python script that will be executed. By default, it is set to ${file} which refers to the file you are actively editing. Just set the value to the file you want to run.

{
   "name": "Python",
   "type": "python",
   "request": "launch",
   "stopOnEntry": true,
   "pythonPath": "${config:python.pythonPath}",
   "program": "main.py",  // Specify the full path to your file
   "cwd": "${workspaceFolder}",
   "env": {},
   "envFile": "${workspaceFolder}/.env",
   "debugOptions": [
       "RedirectOutput"
   ]
},

I should mention that if you are using Windows you can use either forward slashes / or double back slashes \\ in the program path. Single back slashes won't work.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda