Brief Introduction to OpenGL in Python with PyOpenGL

Introduction In this tutorial, we’re going to learn how to use PyOpenGL library in Python. OpenGL is a graphics library which is supported by multiple platforms including Windows, Linux, and MacOS, and is available for use in multiple other languages as well; however, the scope of this post will be limited to its usage in the Python programming language. OpenGL, as compared to other similar graphics libraries, is fairly simple. We’ll start with setting it up on our system, followed […]

Read more

Overview of Async IO in Python 3.7

Python 3’s asyncio module provides fundamental tools for implementing asynchronous I/O in Python. It was introduced in Python 3.4, and with each subsequent minor release, the module has evolved significantly. This tutorial contains a general overview of the asynchronous paradigm, and how it’s implemented in Python 3.7. Blocking vs Non-Blocking I/O The problem that asynchrony seeks to resolve is blocking I/O. By default, when your program accesses data from an I/O source, it waits for that operation to complete before […]

Read more

Python: Append Contents to a File

In this article, we’ll examine how to append content to an existing file using Python. Let’s say we have a file called helloworld.txt containing the text “Hello world!” and it is sitting in our current working directory on a Unix file system: $ cat ./helloworld.txt Hello world! Now assume we want to append the additional text “It’s good to have been born!” to the end of this file from a Python program. The first step is to obtain a reference […]

Read more

Python: Check if String Contains Substring

In this article, we’ll examine four ways to use Python to check whether a string contains a substring. Each has their own use-cases and pros/cons, some of which we’ll briefly cover here: 1) The in Operator The easiest way to check if a Python string contains a substring is to use the in operator. The in operator is used to check data structures for membership in Python. It returns a Boolean (either True or False) and can be used as […]

Read more

Asynchronous Tasks in Django with Redis and Celery

Introduction In this tutorial I will be providing a general understanding of why celery message queue’s are valuable along with how to utilize celery in conjunction with Redis in a Django application. To demonstrate implementation specifics I will build a minimalistic image processing application that generates thumbnails of images submitted by users. The following topics will be covered: The code for this example can be found on GitHub along with installation and set up instructions if you just want to […]

Read more

Image Recognition in Python with TensorFlow and Keras

Introduction One of the most common utilizations of TensorFlow and Keras is the recognition/classification of images. If you want to learn how to use Keras to classify or recognize images, this article will teach you how. Definitions If you aren’t clear on the basic concepts behind image recognition, it will be difficult to completely understand the rest of this article. So before we proceed any further, let’s take a moment to define some terms. TensorFlow/Keras Credit: commons.wikimedia.org TensorFlow is an […]

Read more

The Python zip() Function

In this article, we’ll examine how to use the built-in Python zip() function. The zip() function is a Python built-in function that allows us to combine corresponding elements from multiple sequences into a single list of tuples. The sequences are the arguments accepted by the zip() function. Any number of sequences can be supplied, but the most common use-case is to combine corresponding elements in two sequences. For example, let’s say we have the two lists below: >>> vehicles = […]

Read more

The Python String strip() Function

In this article, we’ll examine how to strip characters from both ends of a string in Python. The built-in String type is an essential Python structure, and comes with a built-in set of methods to simplify working with text data. There are many situations in which a programmer may want to remove unwanted characters, i.e. strip certain characters, from either the beginning or ending of a string. The most common requirement is to strip whitespace (spaces, tabs, newline characters, etc.) […]

Read more

Predicting Customer Ad Clicks via Machine Learning

Introduction Internet marketing has taken over traditional marketing strategies in the recent past. Companies prefer to advertise their products on websites and social media platforms. However, targeting the right audience is still a challenge in online marketing. Spending millions to display the advertisement to the audience that is not likely to buy your products can be costly. In this article, we will work with the advertising data of a marketing agency to develop a machine learning algorithm that predicts if […]

Read more

Creating and Importing Modules in Python

Introduction In Python, a module is a self-contained file with Python statements and definitions. For example, file.py, can be considered a module named file. This differs from a package in that a package is a collection of modules in directories that give structure and hierarchy to the modules. Modules help us break down large programs into small files that are more manageable. With modules, code reusability becomes a reality. Suppose we have a function that is frequently used in different […]

Read more
1 815 816 817 818 819 859