I like print's f-string debugging (written as print (f" {○○○ =} ")
, which was adopted in Python 3.8.
However, with VS Code, the amount of typing is quite large even if you use Intellisense, so I made a snippet myself.
・ How to make a user snippet Menu> "Code"> "Preferences"> Select "User Snippets"> Search for "Python" in the "Search Box"> "python.json" file opens
Add the following description;
python.json
{
"Print f-string debugging": {
"prefix": "print",
"body": [
"print(f\"{$1 = }\")",
],
"description": "print(f\"{ = }\")"
},
"Print with quote": {
"prefix": "print",
"body": [
"print(\"$1\")",
],
"description": "print(\"\")"
},
}
Below is a brief explanation;
--The name "Print f-string debugging" doesn't really matter.
-"prefix" is the character that triggers the snippet.
-"body" is the character that is actually entered. "
must be escaped with\
, $ 1
will be the cursor position, and $ 2
, $ 3
,, will be the next move position when the Tab key is pressed. ..
-"description" is the description when the snippet is displayed.
-"Print with quote" is a snippet of print ("")
that I made incidentally.
I use this snippet a lot.
Recommended Posts