Skip to content

Instantly share code, notes, and snippets.

@pradishb
Last active February 5, 2021 13:37
Show Gist options
  • Save pradishb/633c20b710ef08f4ecdb28645b40e273 to your computer and use it in GitHub Desktop.
Save pradishb/633c20b710ef08f4ecdb28645b40e273 to your computer and use it in GitHub Desktop.
My custom python snippets for VSCode. Includes (main, unittest, cv2.imshow)
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"main": {
"prefix": "main",
"body": [
"'''Main module'''\r\n$0\r\n\r\ndef main():\r\n '''Main function'''\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"
]
},
"unittest": {
"prefix": "unittest",
"body": [
"'''Test module'''\r\nimport unittest\r\n\r\n\r\nclass ${1:classname}Case(unittest.TestCase):\r\n '''Test class'''\r\n\r\n def setUp(self):\r\n ${2:setup}\r\n\r\n def test_(self):\r\n '''Testing function'''\r\n $3\r\n\r\n\r\nif __name__ == '__main__':\r\n unittest.main()\r\n"
]
},
"imshow": {
"prefix": "show",
"body": ["cv2.imshow('', ${1:image})", "cv2.waitKey()"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment