Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Playing Around With IDLE

00:00 IDLE is short for Integrated Development and Learning Environment, and it’s an application that is included in most Python installations. IDLE is a quite basic IDE, but that makes it nice to get into the world of IDEs.

00:15 And since IDLE is an IDE, it offers a REPL and script editing features in one interface. We’ll explore the advantage of this in a moment.

00:25 For now, let’s take one step back because you’re probably wondering how do I get this IDLE editor? And if you’re not sure if it’s on your system, then it might be worth to check out our Python Basics course on setting up Python, and the Starting With Python IDLE course.

00:42 So there you will go through the process of setting up Python with IDLE and taking the first steps in IDLE. There you will also find different ways of where to find IDLE on your system.

00:53 I will show you one way of finding it and maybe it works for you as well. So head over to the terminal again

01:03 and write idle, and when you press Enter, chances are that IDLE opens for you.

01:10 Once you start IDLE successfully, you should see a window titled IDLE shell 3.13 for example, where the actual number corresponds to your Python installation and the rest is very similar to the REPL you already knew from before.

01:26 There are a bunch of information up top and there is this three greater sign prompt that should look familiar to you and you can type the REPL command interactively in this shell just like you did before.

01:39 For example, again, you can write print

01:44 ("Hello, World!"), and once you hit Enter you can see Hello, World!. And you can see a nice thing here as well. The print() function is pink and the string is green.

01:54 So that’s what I meant by syntax highlighting. That makes your code not just colorful and more nice to look at, but it also makes your code more readable.

02:04 So now we’re working with a small line of code, but imagine you have a big codebase there you can have a much, much nicer overview about what’s going on in your code where different syntax are colored differently.

02:18 As mentioned before, one advantage of an IDE like IDLE is that you not only have the REPL, but you have also an area where you can actually create Python files.

02:30 That’s what’s called the editor in IDLE. And to open the editor, you can go to File > New File.

02:39 Once you click New File, you will open an additional editing window. You can see the editing window on the right. Once you click in the editor on the right, you can start typing.

02:50 For example, again, you can write print( and once you hit the parentheses you see something else going on there—the context-sensitive help that an IDE offers.

03:02 So if you start typing print( with the parentheses and haven’t added any arguments or closing parentheses to it, a small pop-up called a tooltip will appear to show you helpful information about how to use the print() function.

03:17 And just like the REPL on the left, you have the syntax highlighting where the string is nicely colored in green and the print() function is pink.

03:27 To save your file, go to File > Save As

03:34 and then you can select the name for your program. Here I call my program hello_program.py and then save the file.

03:44 The next step is to try out the program and run it. And to do so you can go to Run > Run Module.

03:53 When you press Run Module, then you can see that the REPL is restarting. You can see where I saved my file, It’s in a projects folder inside my Documents folder, and you can see the output Hello, World!.

04:05 So that is nice, and you might be wondering like, well, I mean so far it is not that much different than creating the file in the terminal and running it there.

04:14 But the advantage is you can always go back into your editor and make some changes. So for example, instead of “Hello, World!”, you can say “Hello, You Wonderful World”.

04:28 And once you save the file and run the module again, then well you would see the updated text if I would have coded correctly, you may have spotted that I missed a quote there and the IDE lets me know “unterminated string literal (detected at line 2)”.

04:47 That’s another helpful thing that an IDE provides. It points out errors to you. And there you can see that now we have a red box around the first quote informing me that I opened the string but I never closed it.

05:02 And now you can also see another advantage of the syntax highlighting because the closing parentheses on the right is also green and actually only the string should be green.

05:12 So there is definitely a mistake. Let’s put the quote there and since we’re at it, let’s also add an exclamation mark because we are very happy about this wonderful world.

05:23 Save the file again and run the module and now you can see the updated string is printed. Hello, You Wonderful World!. On the left you see the REPL, on on the right you see your editor.

05:37 And when both windows are open, then you can switch back and forth between editing your code and running your code, spotting any errors if they occur, and editing and running your code.

05:47 So this is the perfect flow for improving your Python skills without making life too hard for yourself by either just working in the REPL or by creating files directly in the terminal.

06:01 The last thing I want to show you in IDLE is code completion. When you go to the next line and you would start to write print( and start writing a p, then you can go to Edit >

06:14 Show Completions to see what Python offers with a p. So there is the pass keyword and there are other things that are somehow related to this p, but there is also the print() function.

06:29 That’s a very basic feature in IDLE. In other IDEs it’s way more powerful with much more information there. But it’s nice that it helps you a little bit when you want to write something and you’re not entirely sure what exactly this Python keyword was or how this built-in function was named.

06:48 So using a code editor or an IDE brings actually the same advantages mentioned before when talking about Python files in general, but it adds even more cool things to it.

06:59 So just like before, you can run code repeatedly, you can edit your code, you can back up and share your code because it’s a file and it’s a very good basis for larger codebases.

07:12 It also adds code completion. The other two things you saw there is syntax highlighting, which is helpful and it’s way more convenient to investigate errors if they occur.

07:23 IDLE is a very basic IDE. There are more powerful IDEs like PyCharm or more powerful code editors like VS Code. And they can really streamline your project organization by offering structured views of code files, folders, and so on.

07:39 So we just scratched on the surface with IDLE here. A good organization with all those files and folders in your IDE allows you to visually grasp how different files in a large project connect and interact with each other.

07:54 As you continue your Python developer journey, you’ll probably find a favorite professional IDE or code editor that you spend a lot of time using as you develop your Python programs.

08:04 This could be VS Code, this could be PyCharm, but this could be also another code editor. Whatever fits your groove is perfect, but trust me, even when you are a very experienced programmer, you’ll always cherish your REPL and the terminal when you quickly want to try something out.

08:21 And actually that’s the greatest advantage of all. With all the things I showed you during this course, it’s really nice to have all these many options to interact with Python.

08:31 And with that being said, let’s wrap up the course in the next lesson where I’ll give you some additional resources to dive even deeper.

Become a Member to join the conversation.