Searching The Parse Tree Using BeautifulSoup

Introduction HTML (Hypertext Markup Language) consists of numerous tags and the data we need to extract lies inside those tags. Thus we need to find the right tags to extract what we need. Now, how do we find the right tags? We can do so with the help of BeautifulSoup’s search methods. Beautiful Soup has … Read more

Python any() Function

Python’s built-in any(x) function takes one iterable as an argument x such as a list, tuple, or dictionary. It returns True if at least one of the elements in the iterable evaluates to True using implicit Boolean conversion, otherwise it returns False. If the iterable is empty, e.g., any([]), it returns False because the condition … Read more

Python Regex Finditer()

You can create an iterable of all pattern matches in a text by using the re.finditer(pattern, text) method: Specification: re.finditer(pattern, text, flags=0) Definition: returns an iterator that goes over all non-overlapping matches of the pattern in the text. The flags argument allows you to customize some advanced properties of the regex engine such as whether … Read more

list.clear() vs New List — Why Clearing a List Rather Than Creating a New One?

Problem: You’ve just learned about the list.clear() method in Python. You wonder, what’s its purpose? Why not creating a new list and overwriting the variable instead of clearing an existing list? Example: Say, you have the following list. If you clear the list, it becomes empty: However, you could have accomplished the same thing by … Read more

Python all() Function

Python’s built-in all(x) function takes one iterable as an argument x such as a list, tuple, or dictionary. It returns True if all iterable elements evaluate to True using implicit Boolean conversion, otherwise it returns False. If the iterable is empty, all() returns True because the condition is satisfied for all elements. Argument x -> … Read more

Python abs() Function

Python’s built-in abs(x) function returns the absolute value of the argument x that can be an integer, float, or object implementing the __abs__() function. For a complex number, the function returns its magnitude. The absolute value of any numerical input argument -x or +x is the corresponding positive value +x. Argument x int, float, complex, … Read more

Python Regex – How to Count the Number of Matches?

To count a regex pattern multiple times in a given string, use the method len(re.findall(pattern, string)) that returns the number of matching substrings or len([*re.finditer(pattern, text)]) that unpacks all matching substrings into a list and returns the length of it as well. A few hours ago, I wrote a regular expression in Python that matched … Read more

Web Scraping With BeautifulSoup In Python

Summary: Web scraping is the process of extracting data from the internet. It is also known as web harvesting or web data extraction. Python allows us to perform web scraping using automated techniques. BeautifulSoup is a Python library used to parse data (structured data) from HTML and XML documents. The internet is an enormous wealth … Read more

Python Built-In Functions

Python comes with many built-in functions you can use without importing a library. The following table goes over all built-in functions in alphabetical order. If you click on any of the provided links, you’ll find an in-depth article with a short explainer video on the Finxter blog to help you improve your skills. Just follow … Read more

Python Regex Multiple Repeat Error

Just like me an hour ago, you’re probably sitting in front of your regular expression code, puzzled by a strange error message: Why is it raised? Where does it come from? And, most importantly, how can you get rid of it? This article gives you answers to all of those questions. Alternatively, you can also … Read more

Exponential Fit with SciPy’s curve_fit()

In this article, you’ll explore how to generate exponential fits by exploiting the curve_fit() function from the Scipy library. SciPy’s curve_fit() allows building custom fit functions with which we can describe data points that follow an exponential trend. In the first part of the article, the curve_fit() function is used to fit the exponential trend … Read more

Christian Mayer

Chris is the founder of the programming education company FINXTER, author of the Coffee Break Python series of self-published books, the popular programming book Python One-Liners (NoStarch 2020), a doctorate computer scientist, and owner of one of the top 10 Python blogs worldwide. His research interests include graph theory and distributed systems. You can join … Read more