Python Code

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….

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
Example of a snippet that provides “hello world” via intellisense – note you can also add variables within the snippet
“I Do the Code to Print Hello World”: {
        “prefix”: “hellw”,
        “body”: [
            “print(‘Hello World’)\n”,
            “print(‘Hello to you’, ${user_name})\n”,
        “description”: “This Snippet Prints Hello World”
By typing “hellw” intellisense will insert the snippet of code that you have assigned to that name
This is the code that gets placed into your code that you are currently writing