10

I am trying to find a way to give current file as argument for module. I couldn't find it anywhere so I'm trying stackoverflow

{
    "name": "Python: Synapse",
    "type": "python",
    "request": "launch",
    "module": "projFolder.targetModule",
    "console": "integratedTerminal"
}

Manually specifying the module argument such as above example, works. But thinking of doing that for every each file wanted me to automate it. I've tried ${file}, but it gives the file path not the module. So it didn't work. How can I launch current current file as module?

3

1 Answer 1

11

ps: answer from https://stackoverflow.com/a/57416114/6088796, but I modify a litter

add something like this to your launch.json, but if you want to run multi-module(in a different place, the only way you can do is using multi configuration, or use a plugin(see below)

    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "yourmodule.${fileBasenameNoExtension}",
            "stopOnEntry": true
        },

You can use the extension Command Variable to get this relative directory with dot separator.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Module CmdVar",
      "type": "python",
      "request": "launch",
      "console": "integratedTerminal",
      "module": "${command:extension.commandvariable.file.relativeDirDots}.${fileBasenameNoExtension}",
    }
  ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

there is a combined command: "module": "${command:extension.commandvariable.file.relativeFileDotsNoExtension}",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.