0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

launch.json小ネタ

Posted at

launch.jsonの小ネタ集

launch.json自動生成

1.Ctrl+Pを押してからdebug[半角スペース]と入力、構成の追加を選択

image.png

2.Python Debuggerを選択

image.png

image.png

Python ファイル

現在アクティブな Pythonファイルをデバッグする

launch.json
{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python デバッガー: 現在のファイル",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

引数を含む Pythonファイル

現在アクティブな引数を含む Python ファイルをデバッグします

launch.json
{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python デバッガー: 引数を含む現在のファイル",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": "${command:pickArgs}"
        }
    ]
}

モジュール

Pythonモジュールを'-m'で呼び出してデバッグする

launch.json
{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python デバッガー: モジュール",
            "type": "debugpy",
            "request": "launch",
            "module": "src.sample.hello"
        }
    ]
}
src/sample/
   hello.py
hello.py
def main():
    print("hello world")

if __name__ == "__main__":
    main()

launch.jsonをGit管理から外す

  1. .gitigoreに追加する

  2. .git/info/excludeに追加する

launch.jsonはプロジェクトでGit管理されていないが除外したい場合こちら

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?