Introduction

Python Beginners - IDE Choice. One of the most common choices for all developers is which IDE (Integrated Development Environment) to choose. So first, let us look at an IDE and why you might want to use something other than Idle when writing Python Code. I.D.E. stands for Integrated Development Environment. This means it is a set of tools to aid in software development combined into a single application. The standard components of an IDE are syntax highlighting, debugging and code suggestions. IDLE does some of this. However, it does highlight syntax, as seen when the commands change to another colour while typing and the areas between quotation marks. Many people will find the video version of this more accessible to follow than the text-based blog. The video version is available at the bottom of the blog or by clicking here.

IDEs Disscussed - Python Beginners - IDE Choice

Idle

Idle is the basic IDE included with Python when the interpreter is installed on a computer system and is frequently the first IDE Python developers use.

Thonny

Thonny is an IDE for beginners made by the University Of Tartu. Its aim is to support new Python developers.

Visual Studio Code (VsCode)

Visual Studio Code (VsCode)is a lightweight open-source IDE from Microsoft. Some languages have better Intellisense and Debugging than others. Python is one of the most robust extensions for VsCode. My opinion is that for basic Python programming, VSCode is just as good as Visual Studio (Microsoft's fully fledged IDE).

Pycharm

Pycharm is a lightweight open-source IDE from Microsoft. Some languages have better Intellisense and Debugging than others. Python is one of the most robust extensions for VsCode. My opinion is that for basic Python programming, VSCode is just as good as Visual Studio (Microsoft's fully fledged IDE).

Visual Studio

Visual Studio is a professional IDE by Microsoft. In some languages, it is the Gold Standard IDE. C# and C++ are among those languages. However, Python isn't. Like PyCharm, it can be complex and daunting for new developers. However, it is an excellent IDE and probably the most used IDE.

Syntax Highlighting - Python Beginners - IDE Choice

Syntax highlighting is a way of helping coders read their code. Different areas of code are coloured differently. Note that different IDE's and even the same IDE with different settings will display the different colours. See the code below:


name = input("your name please")
if name == "Ms Payne":
    print("you are " + name)
else:
    print("You are not Ms Payne")

While typing the program, the text will highlight when commands are recognised. This additional level of interaction helps new coders see if they have typed the command correctly. Every IDE and editor uses different colours but still separates the code's other areas. One of the significant advantages of a professional IDE is the ability to customise the syntax highlighting to suit your tastes. For example:

Idle Syntax Highlighting - Python Beginners - IDE Choice

image showing a simple program in python with the syntax highlighting in IDLE - Python Beginners - IDE Choice

Thonny Syntax Highlighting

thonny syntax highlighting light mode - Python Beginners - IDE Choice thonny syntax highlighting dark mode

Light Mode / Dark Mode

PyCharm

images of pycharm syntax highlighting - Python Beginners - IDE Choice images of pycharm syntax highlighting dark mode

Visual Studio

images of visual studio syntax highlighting with python - Python Beginners - IDE Choice images of visual studio syntax highlighting with python - dark

VsCode

vscode python syntax highlighting, light mode - Python Beginners - IDE Choice vscode python syntax highlighting, dark mode

Syntax Highlighting Summary

All the IDEs listed provide the ability to show syntax highlighting. All except Idle come with themes that allow easy changing to colour schemes others have found useful. Idle will enable you to customise the highlighting, but not quick theme changes.

Predictive Coding (IntelliSense) - Python Beginners - IDE Choice

IntelliSense, or predictive code snippets, is a handy feature provided by some IDEs. Neither IDLE nor Thonny does not support this feature, but PyCharm, Visual Studio and VsCoode all do. I am adding written and video versions of this section because I think this is easier to show and understand using video. However, for those who dislike videos, I am also adding images. IntelliSense will help while you type by offering suggestions based on what you have typed up to that point. I will write a variable, assign a value and then a print statement to show this and add images of the IDE's suggestions.

PyCharm IntelliSense

Image of Intellisense in PyCharm, stage 1 - Python Beginners - IDE Choice Image of Intellisense in PyCharm, stage 2 - Python Beginners - IDE Choice Image of Intellisense in PyCharm, stage 3 - Python Beginners - IDE Choice

When you type the letter 'p', PyCharm offers a list of commands starting with 'p'. Wight each additional character will narrow down the possibilities. Highlight the one you one, or click enter when it is. It will add that code. In this case, the print command with the open and close parenthesis is already in place. Next, typing the letter 'n' detects the variable above it that starts with the letter 'n'. Click enter at this point, and the variable name is filled in for you. In my opinion, PyCharm offers the best IntelliSense of all these IDEs for Python.

VsCode IntelliSense

image of vs code intellisense with python stage 1 image of vs code intellisense with python stage 2 image of vs code intellisense with python stage 3

VsCode offers print as soon as you type the letter 'p'. However, it does not add the parenthesis automatically. However, it automatically adds the closing parenthesis and puts the cursor in the middle of them. Then when typing the letter 'n', the first suggested offer is not 'name'. The variable 'name' is in the list, but it requires typing more characters or using the cursor keys or mouse to select it.

Visual Studio

image of intellisense in visual studio with python stage 1 image of intellisense in visual studio with python stage 2 image of intellisense in visual studio with python stage 3

VsCode offers print as soon as you type the letter 'p'. However, it does not add the parenthesis automatically. However, it automatically adds the closing parenthesis and puts the cursor in the middle of them. Then when typing the letter 'n', the first suggested offer is not 'name'. The variable 'name' is in the list, but it requires typing more characters or using the cursor keys or mouse to select it.

IntelliSense Summary - Python Beginners - IDE Choice

PyCharm was clearly the best at providing Intellisense in the limited examples in this post. It is possible other situations would reverse this result. However, based on personal experience, PyCharm consistently performs better than any other Python IDE in this area.

Debugging - Python Beginners - IDE Choice

All the IDEs in this article support debugging. However, there are differences in the debugging level and its implementation's usefulness. Debugging allows code to be executed step by step. Usually, a breakpoint can be set. The code will run up to the breakpoint, stop, and wait for user prompts. In addition, many debuggers allow conditional breakpoints that only trigger when the condition is met. Finally, some IDEs allow manually changing variables while the code executes, enabling coders to test values likely to cause issues. One of the other ways a debugger can help is by watching how the code behaves through a loop or selection. For most people, the video version of this will be more straightforward. However, for those who prefer reading, I will also add images. Since this series has not yet covered looping or selection, I will show how it works with the same code as above. There is a selection in the code. The 'if' statement checks to see if the user enters the characters 'Ms Payne'. Then, it does one of two things depending on the answer.


name = input("your name please")
if name == "Ms Payne":
    print("you are " + name)
else:
    print("You are not Ms Payne")

IDLE Debugging

Getting Started

Idle requires a few stages to make debugging work.

  • Go to the Debug menu in the shell window, then choose Debugger. This will open a new window.
Image of the IDLE debug window - Python Beginners - IDE Choice
  • Set a breakpoint, and right-click on the line you wish the code to stop executing. For your first experiment, the first line makes sense.
image of how to set a break point in idle - Python Beginners - IDE Choice

After the breakpoint is set, the selected line has a highlight.

Walk Through

Next, in the script window, click Run and then Run Module. Arranging the three windows so you can see them all makes sense. In the debug window, the buttons are now active.

idle debugger stage 1, shell, script and degger visible after the program has been run  - Python Beginners - IDE Choice

If you look closely at the highlighted line in the debugger, it shows the first line of code as the current execution point. Pressing the Over button will bring up the input request in the shell window. Pressing the Step button several times will achieve the same thing. IDLE's debugger isn't excellent to use. Step shows many stages the coder does not typically want to see when pressed.

idle debugging, script window asking for user input - Python Beginners - IDE Choice

Type "Ms Payne" into the shell window without quotation marks and press the enter key. Press the Over button again and look at the highlighted code in the debugger window. It shows line 3 because the characters typed match the ones in the 'if' statement quotes.

idle debugger showing the if statement in the debugger - Python Beginners - IDE Choice

Finally, press the over button once more, and the print statement will execute, and the output will show in the shell window.

idle debugger showing the if statement in the debugger - Python Beginners - IDE Choice

Repeat the process by rerunning the code. However, enter anything besides "Ms Payne" when it asks for user input. Watch for the difference in the debugging window after the user enters the data.

idle debugger showing the if statement in the debugger - Python Beginners - IDE Choice

This time, it will show the print statement in the "else" section of the code. The other IDEs handle this process significantly better than IDLEs. However, since IDLE is a simple and easy starting point for most users. It was worth fully showing this process so you can understand the differences.

Thonny Debugging

Thonny is a slimline IDE designed for beginners. It supports debugging but lacks some of the features of professional IDEs. However, the interface is significantly less complicated. Start by left-clicking over the line number you wish to start debugging at; doing this on line one is sensible for this demonstration. A red dot will appear next to the number.

image of Thonny showing a break point on line 1 - Python Beginners - IDE Choice

Next, click on the little green bug button. Hovering the mouse over it will show "debug script".

Thonny debug stage 1-1

In the above image, three more buttons are now active to the right of the debug button, and the line with a breakpoint is highlighted. Next, click on the Step Into button. It will now process the 'input' section of code; with each click, you will see the action section of code being processed.

image of Thonny in the first stage of debugging an input statement

Either keep clicking Step Into or switch to Step Over. It will stop at the point it needs user input.

image of thonny running through all the background steps using step into

Type in "Ms Payne" without the quotes and press the enter key. At first, nothing will happen, so after pressing the enter key, press the step into button again. It will highlight the entire if/else block.

image of thonny selecting an entire if/else block

Pressing Step into a further time will highlight the section of code it's checking.

image of thonny selecting an entire if/else block

Repeat pressing the Step Into button to observe each step until you see it evaluate the statement as True.

image of thonny selecting an entire if/else block

Because it evaluates as True, the code inside the 'if' statement is highlighted.

image of thonny selecting an entire if/else block

Repeat pressing the Step Into button to see each stage of the print command. In the end, the contents of the variable are output.

image of thonny selecting an entire if/else block

Repeat the process from the beginning, experiment with changing the text you enter as a user, also experiment with Step In and Step over to observe the difference. Thonnys debugging is much better than IDLE because it visually shows the code about to execute.

VsCode Debugging

VsCode is Microsoft's lightweight IDE. It uses fewer resources than Visual Studio but isn't usually as lovely. However, it supports pretty much any language with extensions, including Python. Setting up Vs-Code jumps up a level in complexity. The IDE creates a virtual Python Environment and needs the Python executable to be present in the system path statement. Once set up, it works much more excellently than IDLE or Thonny. Start by left-clicking on the line number you wish to start debugging on; a red dot will appear there.

image of VsCode editing a ptyon program after the breakpoint has been set

Click on the Run menu, choose Start Debugging, or press the F5 key.

image of vscode with the run menu open

Vs-Code will stop where the breakpoint is set and highlight the line. Additionally, the debugging toolbar pops up. Hover over them to see what each button does.

image of VsCode editing a ptyon program highlighting the first debug line

Click on the Step Into button; the behaviour differs slightly from the previous two IDEs. It jumps straight to asking for the user input. Similarly to before, type in "Ms Payne" and press the return key. After hitting return, nothing will happen until you click "Step Into" again.

image of VsCode editing a ptyon program highlighting the first debug line

Notice how it acts more intelligently than the previous two IDEs. The left-hand pane shows us the value of the variable called Name, then highlights the following line of code it will run. It doesn't bother telling you about all the other stages (by default). Click the step into button once more.

image of VsCode at the end of a debug process with python code.

The little popup box in the bottom right alerts users that some stages were skipped. Clicking on the blue information circle will guide users to the setting that controls this feature.

Debugging PyCharm

Introduction

JetBrains PyCharm is the first of the two professional-level IDEs. Unlike Vs-Code, it is not necessary to add the Python Interpreter to the system path statement; however, it does require knowing where that is on the system when setting up the IDE instead. In addition, each time you create a new project, there are options to choose from that new developers will be unfamiliar with, like the location of the interpreter on the HDD and the idea of inheritance from global packages. I will be adding a separate post on starting with PyCharm later. It sounds like a lot of work, but it is worth it once you're used to the steps.

Walk Through

Start by left-clicking on the line number to add a breakpoint. It will place a red dot next to it. Then click on the green bug icon in the top right of the IDE to start debugging.

pycharm debugging python code with a breakpoint set and highlighted

PyCharm has the beginning controls in the bottom left pane. The symbols should look familiar now. However, there is an extra option. Where VsCode only lets you choose between "Step Into" or "Step Into My Code", PyCharm puts this control at developers' fingertips. This means it's easy to control the difference at each debugging stage. Click on the step into my code button for a more sensible experience.

pycharm debugging python code, enteringn the input stage

Type in "Ms Payne" and click the enter key. If the Debug tab is not highlighted at the bottom of the screen, you will need to click that to type the response. This is one way in which PyCharm is more complex. There are many more features available that new developers are unlikely to use. Consequently, the interface takes a bit more learning.

pycharm debugging python code showing the value entered into a variable

Notice how the highlighted first line has changed colour in the above image. Additionally, the value it has just stored in the "name" variable is clearly displayed, making it very clear what has happened. Click on "Step Into My Code" again.

pycharm debugging python code showing the print statement inside an else block

The line it will execute next is highlighted; click on the "Step Into My Code" button once more.

pycharm debugging python code showing the end of the debug process

The program outputs the print statement into the debug pane and exits. PyCharm has by far better handling of debugging than IDLE, Thonny or VsCode. It just comes at the cost of complexity. The interface can seem daunting at first.

Visual Studio Debugging

Visual Studio is a professional-level IDE by Microsoft. In C# and C++, it is the Gold standard for an IDE. Setting a breakpoint is very similar to most of the other IDEs. However, it will highlight the breakpoint line before debugging starts.

Visual Studio debugging Python code showing the break point set and highlighted

The next difference is that visual Studio has a drop-down menu to choose between debug and release. However, it defaults to debug. Then click the "Start" button to begin debugging.

Visual Studio debugging Python code showing the start of the debug process with the console window open

Unlike any other IDEs, Visual Studio opens a separate console window. It has the familiar "Step Into" and "Step Over". However, the option to choose between "Step into Your Code" or "Step In" is in the settings like it was with VsCode. Like VsCode, the default is to only step into your code. Click on Step In; the question appears in the Console Window. For example, type In "Ms Payne", then click the enter key.

Visual Studio debugging Python code showing the input state inside the console window

Click the Step Into Button again

Visual Studio debugging Python code showing the print statement inside the else block highlighted

Unlike PyCharm, the value stored in the variable 'name' is harder to see. This is because you have to hover the mouse over it. This is another way also supported in PyCharm. Click on Step into once more to finish.

Visual studio debug last stage

Visual Studio outputs the print statement into the console and provides a popup box to tell the user about skipped stages and how to change this in the settings.

Debugging Summary - Python Beginners - IDE Choice

PyCharm is a clear favourite for debugging functionality. It puts more flexibility at developers' fingertips to change how they work at each debugging stage. The level of complexity between Visual Studio and PyCharm is comparable, but both and considerably more complex than VsCode, which is, in turn, significantly more difficult than Thonny. IDLE is very poor for debugging and probably not worth trying.

Overall Summary - Python Beginners - IDE Choice

IDLE does not support Intellisense at all. Debugging in IDLE is clumsy and difficult to navigate. Consequently, it is not an IDE to consider for serious development. However, it is a perfect place to begin a coding journey due to its simplicity. Thonny drastically improves the debugging situation. It is probably an excellent second step. However, the lack of IntelliSense prevents it from being a realistic option for developing anything other than tiny programs. Perhaps predictably, the three that developers will quickly migrate onto are VsCode, PyCharm and Visual Studio. After your first few experiments with Python code, it is worth investing time to learn how to set up and use one of them. VsCode is entirely open source and free, including the extensions. There is a community edition of Visual Studio, which you can use for non-commercial purposes. Finally, PyCharm has a community and education edition and professional licences. Posts on setting up VsCode, PyCharm and Visual Studio will come soon. PyCharm by JetBrains focuses on Python. JetBrains provide a suite of IDEs for different languages. VsCode and Visual Studio are multi-language IDEs and do not focus on Python specifically. Professional developers are likely to only consider Visual Studio or PyCharm.

Video Version - Software Setup

Python

Windows

Ubuntu(Linux)

Ubuntu 22.04 and later, along with recent Debian versions, come with Python3 installed as part of the standard installation. First, check python is installed with


python3 -V

The expected output is.

Python 3.9.13

The version might not match exactly, but it should be higher than 3. If Python3 is not installed, install it with.


sudo apt install python3

Next, extra packages are needed to allow other software, such as PyCharm and VsCode, to make virtual environments.


sudo apt install python3-pip build-essential libssl-dev libffi-dev python3-dev python3-venv

The above is sufficient to allow other software to create virtual environments.

PyCharm

Windows

Ubuntu(Linux)


sudo snap install pycharm-community --classic

Alternatively, it can be downloaded as a tar file, extracted and run directly. There is also a friendly toolbox app that will install any of the JetBrains applications available.

VsCode

Windows

Ubuntu(Linux)

VsCode is available in the snap store; it is a version compiled by a 3rd party and does not get frequent updates. However, it will install without complications on all Ubuntu systems. It is possible to install Microsoft's version using apt. First, download the deb file from the VsCode Downloads page . Then, open a terminal and navigate to the downloaded file.


ls

The output should contain a file similar to the one below.

code_1.74.3-1673284829_amd64.deb

Next use dpkg to install the application. If your download has a different version number, update it in the dpkg command below.


sudo dpkg -i code_1.74.3-1673284829_amd64.deb

If there are warnings about dependency errors, a likely fix is


sudo apt-get install -f

Visual Studio

Windows

Thonny

Windows

Ubuntu(Linux)

Open a terminal and use apt.


sudo apt install python3-tk thonny