Python
Python Web Scraper: super easy basics for beginners
In this tutorial, we will learn Python programming by working on a beginner project: a Web Scraper. With this project we will learn the basics of web scraping: A web scraper is a tool that gathers data from web sites to be used in an application. For example, news, prices on a store’s website, event information on an event page, etc. That data can then be used for analysis, reporting, to train an artificial intelligence (AI). A web scraper might sound like a big and difficult project but we will begin small and slowly build it up. We will start…
Visual Studio Code debugger for Python: how to use
In this tutorial, you will learn how to use the Visual Studio Code debugger for Python. Knowing how to use a debugger is a valuable skill for when programming. But a debugger is also very useful when you’re learning how to program. We will learn the basics of using a debugger and see examples of how it can help you learn programming. I have another useful beginner tutorial for Python about virtual environments: Python Virtual Environment (venv): easy guide for beginners. Contents1 What is a debugger?1.1 Breakpoints1.2 Conditional Breakpoints1.3 Step over/into/out1.4 Viewing the call stack1.5 Watch expressions2 How to use…
Python and React Web App for beginners: start now
In this tutorial, you will gain programming skills by learning how to build a Python and React web app from scratch. Namely, we will build a simple app for writing notes. We will learn what a back end is and what a front end is. The app we are going to build will have a Python back end and a TypeScript React front end. The back end can process and store data, and it also handles requests from the React front end. Our project’s front end will let users see and edit the data. Because this tutorial is aimed at…
Python Virtual Environment (venv): easy guide for beginners
When diving into Python programming, one of the most useful tools you’ll encounter is the virtual environment, often referred to by its tool name venv. A virtual environment for Python is used to manage the dependencies of Python packages. Even though beginner Python programmers might not be concerned with dependency management. And some might not even be aware that it could be a problem. However, it will save you a lot of headaches if you get into the habit of using virtual environments for your projects as soon as possible. What is a Virtual Environment? In Python, a virtual environment…
Mocking in python tests: practical examples
What is mocking when it comes to python tests? Mocking is a way to simulate and control the behavior of functions or objects. Typically this type of control is necessary when unit testing code that deals with systems external to our own code. Why mock external systems? The main issue is with external systems unpredictability, we have limited control over the state of these external systems, making tests potentially very brittle. For example when code reads data from disk or a database. If there is a piece of functionality that reads and modifies files on disk we would have to…
Continuous testing python code with pytest: how to
In this article, we will look at simple and straightforward ways to set up continuous testing of python code for your local machine. After we complete these steps we will be able to get real time updates to test results in a terminal every time we save a code file. You can find an example project in the following repository. Why continuous testing The main motivator to having continuous testing is, instantly letting us know when a code change has broken some piece of functionality. Continuously testing python code will give us confidence that our code is robust. Furthermore, Continuous…
Automated testing for a Flask API: useful examples
In this article, we will look at simple, straightforward, and practical ways of automated testing of the flask REST API we built in this previous article. The completed project can be found in the following github repository: https://github.com/tmsdev82/collectors-items-at-rest Why continuous testing The main motivation for having continuous testing is that it instantly lets you know when a code change has broken some (piece of) functionality. It also lowers the bar to do major code refactoring, because we are assured that the tests are continuously running and if something goes wrong we immediately know about it before it becomes a problem.…
Dockerized Flask RESTful API: how to
We are going to build a simple dockerized Flask RESTful API for managing collectors items. We will do this by implementing a simple REST API that let’s a client application manipulate a collectors_item resource. The REST API we will build will allow create, read, update, and delete actions on collectors_items. We will use the Python library Flask to do this. Together with a number of Flask plugins to make things easier. At the end we will also dockerize this API. In will continue to build out this project in other tutorials. For that reason, we need a solid, scalable foundation,…