To learn more about the concepts in this lesson, you can check out:
Setting Up the Development Environment
Set Up the Development Environment. The first practical step is creating a virtual environment for the project. A virtual environment provides an isolated Python interpreter and a space to install your project’s dependencies. For more on virtual environments, see this Real Python course. To start, go ahead and create the project’s root directory, called
In both of these, the first command creates a fully functional Python virtual environment called
venv inside the project’s root directory. The second command, which is the difference between Windows or macOS, activates the environment.
With this command, you install
aiohttp into your virtual environment. You’ll use this third-party library along with Python’s
async features in the app. Note that in this course, Python 3.10 is being used alongside
aiohttp 3.8.1. In this course, any code that’s executed in Python will be shown using the BPython REPL, which provides a number of improvements over the standard Python one, including color coding. However, all of the code that you see running will work in the standard Python intepreter, which you can access by typing
python at your command prompt.
02:11 Python is surprisingly flexible when it comes to structuring applications, so you may find pretty different structures from project to project. However, small installable Python projects typically have a single package, which is often named after the project itself.
Following this practice, you can organize your app using the directory structure that’s seen on screen. You can use any name for this project and its main package. In this course, the project will be named
rpchecker as a combination of Real Python and checker, which points out the app’s main functionality.
README.md file will contain the project’s description and instructions for installing and running the application. Adding a README file to your project is a best practice in programming, especially if you’re planning to release the project as an open source solution.
requirements.txt file will hold the list of your project’s external dependencies. In this case, you only need the
aiohttp library, because the rest of the tools and modules that you’ll use are available out of the box in Python’s standard library.
Note that you won’t be adding content to the
README.md file in this course, but it is included in the course materials, which you can download inside the
rpchecker/ directory. You have the following files:
rpchecker as a Python package,
__main__.py works as an entry-point script for the app,
checker.py provides the application’s core functionalities, and
cli.py contains a command-line interface for the application.
05:10 Now that everything is in place, you can start writing code. This is what you’ll be doing in the next part of the course, where you’ll be creating the core functionality of the project: checking whether a site is online or not.
Become a Member to join the conversation.