Python: 5 ways to remove HTML tags from a string
Updated: May 20, 2023
This concise, example-based article will walk you through some different approaches to stripping HTML tags from a given string in Python (to get plain text). The raw HTML string we will use in the examples to come is shown......
Python: 2 Ways to Extract Plain Text from a Webpage
Updated: May 19, 2023
The raw HTML data of a webpage includes many things, from HTML tags, images, JavaScript codes, etc. Sometimes, you just need plain text for data analytics, machine learning, or something else. This article will show you 2 ways to get what......
Python: Checking System RAM/CPU/Disk Usage
Updated: May 19, 2023
This succinct, practical article shows you how to programmatically check RAM (memory), CPU, and disk usage in Python. You can get the job done painlessly by using a package called psutil. Install it by performing the following......
Python Generic Types: Tutorial & Examples
Updated: Mar 04, 2023
This concise article is about generic types in Python. Overview Generic types allow us to define classes, functions, or methods that can work with different data types without specifying the exact data type beforehand. This is......
Python: Defining Functions with Type Hints
Updated: Mar 04, 2023
This concise, example-based article shows you how to define functions with type hints in Python. Overview Python 3.5 introduced Type Hints which allows you to specify the data type of a function’s parameters and return value.......
Python Data Types Cheat Sheet
Updated: Mar 04, 2023
A succinct, comprehensive cheat sheet for Python data types. You can use it for quick lookup during your work. TypeDescriptionExampleintinteger values123, -120, 0floatfloating-point values1.21, 3.141, -9.8boolBoolean valuesTrue,......
Python: How to Use Class Decorators with Dataclass
Updated: Mar 01, 2023
This concise, straight-to-the-point article shows you how to use class decorators with dataclass in Python. We’ll take a look at the fundamentals and then walk through a couple of practical examples. The......
Python: How to Set Default Values in Dataclass
Updated: Mar 01, 2023
This succinct, straightforward article shows you how to set default values in a dataclass in Python. Setting Default Values in Dataclass To set default values in a dataclass, we can use simple syntax like a variable declaration or......
Python: How to Validate Data in Dataclass
Updated: Mar 01, 2023
This concise example-based article shows you how to validate data with Python dataclasses. Basic Example Data validation is an essential part of any data processing system. It ensures that the data received by the system is correct......
How to Use Inheritance with Dataclass in Python
Updated: Mar 01, 2023
The dataclasses module brings to the table a great way to create simple and lightweight data structures in Python. However, sometimes you need more complex data structures that require inheritance. Inheritance is a powerful feature in......
How to Use Dataclass Methods in Python
Updated: Mar 01, 2023
The dataclasses module in Python provides a convenient way to define classes with a minimal amount of boilerplate. By adding the @dataclass decorator to a class, Python generates several default methods automatically. In this practical......
Python: Defining Fields in Dataclass
Updated: Mar 01, 2023
This quick article explains the different types of fields that can be defined in a dataclass in Python, as well as covers the different parameters that can be used to define fields. Types of Fields When defining a dataclass in......