How to set up Python IDLE: Python Text Editor
There are lots of text editors (python IDLE) and IDE (Integrated Development Environment) for Python.
A code editor is a tool that is used to write and edit code. They are usually lightweight and can be great for learning purposes. However, it’s not suitable for software or web development purpose. Examples such as notepad, notepad++, python IDLE (Integrated Development Learning Environment).
An IDE (Integrated Development Environment) understands your code much better than a text editor. It usually provides features such as build automation, code management, testing, and debugging. This can significantly speed up your work since it has a feature of auto-completion. The downside is that IDEs can be complicated to use.
IDE/Code Editor for:
1. IDE for Learning
If you are a beginner learning how to code in python, then we recommend using text editors rather than going for IDE. Some of the few text editors are mentioned below and we will discuss more on python’s official text editor IDLE (Integrated Development and Learning Environment).
IDLE is Python’s Integrated Development and Learning Environment. It is a perfect tool for beginners.
IDLE has the following features:
- Coded in 100% pure Python, using the Tkinter GUI toolkit.
- Cross-platform: works mostly the same on Windows, Unix, and macOS.
- Python shell window (interactive interpreter) with colorizing of code input, output, and error messages.
- Multi-window text editor with multiple undo, Python colorizing, smart indent, call tips, auto-completion, and other features.
- Search within any window, replace within editor windows, and search through multiple files.
- Debugger with persistent breakpoints, stepping, and viewing of global and local namespaces.
- Configuration, browsers, and other dialogs.
IDLE is a decent IDE for learning as it’s lightweight and simple to use. However, it’s not for bigger projects.
How to install Python IDLE
1. Download the Python IDLE from here (https://www.python.org/downloads/).
Download the software based on your system Specification (32 bits or 64 bits). Check for the latest stable version.
2. Run the Installer (double click to open it) once it is downloaded.
3. Check the box to Add Python to PATH and Click Install Now.
4. Once you are done Click Finish Button.
You can customize the python IDLE based on your choice and preference. You can change the theme, font style, font size, and a lot more. Follow the steps mentioned below to configure the IDLE:
- Click on Options in the menu bar.
- ‘Show Line Numbers’ will enable the numbering to the lines of code you are writing. It is a good practice to enable these features since it will help to identify the error when your code generates some errors.
- Click on Configure IDLE. It will display the window displayed below.
- Fonts/Tabs menu: You can customize font face, font size, and font style, and indentation width.
- Highlights: You can change text color, background, and foreground color and also the theme of the IDLE.
- Keys: You can customize the shortcut action keys
- General: Here you can do the general setting such as windows preferences, editor’s preferences, and shell preferences.
- Once you are done configuring the IDLE upon your preferences, click on Apply.
- Click OK
Once the installation is successful, we can use Python IDLE as an interactive interpreter as well as a text editor.
IDLE as an Interactive Interpreter(Shell)
The best place to experiment with Python code is in the interactive interpreter, otherwise known as a shell. Python shell will open immediately when you open python IDLE. It reads a Python statement, evaluates the result of that statement, and then prints the result on the same screen. However, revisiting your code and modifying later is not convenient if the code is written in a Python shell. Therefore, you should write code in Text Editor.
IDLE as Text Editor
A file editor enables us to write code, save, edit or modify, and execute. Files will be saved in the .py extension. We recommend you write code in File Editor rather than in Shell.
Steps to open a file editor in IDLE:
1. Open Python IDLE
2. Go to the File menu
3. Click on New File (Ctrl + N)
4. Start writing your code
5. Once you finish writing your code, click on the Run menu.
6. Click on the Run Module.
7. Save your code, when the Run module prompts you to save.
8. Give a file name and Choose file type as ‘python files’ (by default it will be chosen)
9. You will see your output in Python Shell Window.
Other text editors such as Sublime Text Editor, Atom, and VIM to name a few are also used. There is also online text editors used such as Google Colab and Repl editor.
2. IDE for Development
IDE for development purposes is mostly used by a professional developer to develop web applications and software. It provides features such as intelligent code completion, code inspections, error-highlighting and fixes, debugging, unit testing, version control system, code refactoring, and so on. Few IDE for the developer are listed below:
Running Python code in a Window Terminal
Open a command window and enter python in lowercase. You should see a Python prompt (>>>), which means Windows has found the version of Python you just installed.
If you don’t see this output or something similar, that means you forgot to select the checkbox labeled Add Python to PATH while installing python. You should reinstall the python or else you should manually set a python path to the system environment variable.
Open a command window and enter python in lowercase. You should see a Python prompt (>>>), which means Windows has found the version of Python you just installed. Enter the following line in your Python session, and make sure you see the output Hello Python!
Any time you want to run a snippet of Python code, open a command window, and start a Python terminal session. To close the terminal session, press CTRL+Z and then press Enter, or enter the command exit().
Final note: If you are a beginner, python IDLE is recommended otherwise you can use other advanced python IDE mentioned above.