Debugging Python Code
& using Snippets
This article will cover how to achieve the following, using Python :
- Reduce the need for print statements
- Reduce the need to type repetitive code
Why not automate some of your coding to allow you to automate the ‘boring stuff’ – anything that you do regularly could be saved as a snippet and you won’t have to type that section of code from scratch each time….
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image.png)
If you find you have print statements everywhere, or are repeating the same code in many projects then this will be of interest.
First, these are the 3 shortcuts you will want to memorise:
![vscode shortcuts](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-2.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-4.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-5.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-6.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-7.png)
“I Do the Code to Print Hello World”: {
“prefix”: “hellw”,
“body”: [
“print(‘Hello World’)\n”,
“print(‘Hello to you’, ${user_name})\n”,
“$2”
],
“description”: “This Snippet Prints Hello World”
}
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-8.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-10.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-9.png)
![](https://redandgreen.co.uk/wp-content/uploads/2021/03/image-11.png)