Articles about Python

Python Logo

Python is one of the most versatile programming languages in the world. With Python, you can control electronics, build web applications and perform machine learning.

In this page, you can find articles on Python references, coding and application setup.

Rendering multiple checkboxes with WTForms and Bootstrap

When you use WTForms and Bootstrap, you can quickly build up the dashboard for your own content management system with Python.

This is because WTForms provide several out-of-the-box implementations for rendering some basic fields that for capturing form data.

However, rendering multiple checkboxes can be open to different UI implementations based on users’ preferences. Therefore, different fields and widgets are available in WTForms to cater for different ways of displaying a form input to the user.

Given these points, let’s see how we can render multiple checkboxes with WTForms and Bootstrap.

How to use your Raspberry Pi for Python development

Since its inception, the Raspberry Pi had progressed by leaps and bounds. Indeed, one of the reasons why we want to get a Raspberry Pi is its versatility. Apart from the huge selection of hardware, there are many Python libraries for you to build Raspberry Pi applications.

If you want to build something out of a Raspberry Pi, then you will benefit from setting up one for Python development.

Even if you do not build Raspberry Pi projects for a living, setting up a Raspberry Pi Python developer machine can be useful. For example, you may be a Solutions Engineer who build proof of concepts for demo purposes. In this case, you can build your demos with Python and run them on your Raspberry Pi.

If you are thinking of using Raspberry Pi for Python development, then this post is a reference for you.

How to get an Access Token to integrate with PayPal REST APIs in Python

Before you can integrate with PayPal via the REST APIs, you will need to obtain an access token.

Given that REST APIs is agnostic to programming languages, you can use a programming language of your choice to get the Access Token.

In case you are wondering how you can get an Access Token to integrate with PayPal REST APIs in Python, this is how you can do so.

How to use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint

If you want to direct someone to a web page without saying a word, then you can use QR codes to do so.

For example, your QR code reader will direct your phone’s browser to visit our home page when you scan the following QR Code:

Techcoil home page QRCode

Given that, you can use QR codes to send HTTP requests to an endpoint of your HTTP server. In addition, you can embed data that you wish to send to the endpoint in the QR codes.

With this in mind, let’s look at how we can use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint.

How to use threading.Condition to wait for several Flask-APScheduler one-off jobs to complete execution in your Python 3 application

Previously, I discussed how to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request.

When we run jobs as discussed in that post, jobs are ran once by the underlying ApScheduler instance. In addition, our Flask endpoint return the HTTP response back to the HTTP client as soon as the jobs are scheduled.

If we do not want the HTTP client to know the outcome of the jobs within that HTTP call, then we are good. But what if we want to include any errors that the jobs encounter in the same HTTP response?

In such a situation, we will need a mechanism to wait for the one-off jobs to complete execution before returning that response.

Given that in mind, this post shows how we can use threading.Condition to wait for several Flask-APScheduler one-off jobs to complete execution.

How to create an interval task that runs periodically within your Python 3 Flask application with Flask-APScheduler

Previously, I talked about how to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request.

If you wish to run long running tasks triggered by an HTTP request, then that post will help you do so.

However, what if you want to run jobs periodically without blocking your Flask HTTP server from serving HTTP requests?

In this case, you will want to run an interval task with Flask-APScheduler.

Given that, let’s look at how we can use Flask-APScheduler to create an interval task within your Python 3 Flask application.

How to setup MicroPython WebREPL on your ESP32 development board

When I wrote about setting up MicroPython on an ESP development board, I came across the WebREPL.

If you setup MicroPython WebREPL on your ESP32 board, then you can interact with your ESP32 board wirelessly.

In case you need it, this is how to setup MicroPython WebREPL on your ESP32 development board.

How to setup MicroPython on your ESP32 development board to run Python applications

When my friend Youssef shared a link to MicroPython, I kept it at the back of my mind. Since I had found some time to sharpen my saw, I decided to take a look at it.

If I get familiar MicroPython, then I can perform machine learning magic with an AIOT board like Sipeed Maixduino Kit with greater ease.

Given that in mind, here are the steps that I took to setup MicroPython on my ESP32 development board to kickstart my learning.

In case you wish to setup MicroPython on your ESP32 development board to run Python applications, read on to find out more.