How to Print Exception Messages in Python (Try-Except)

Python comes with extensive support for exceptions and exception handling. An exception event interrupts and, if uncaught, immediately terminates a running program. The most popular examples are the IndexError, ValueError, and TypeError. An exception will immediately terminate your program. To avoid this, you can catch the exception with a try/except block around the code where … Read more

Making $1M Every Year with 0 Employees: How an Unassuming Millionaire Coded Photopea All By Himself

This guy makes an annual profit of $1M+ with zero employees and only $700 yearly maintenance costs. Ivan Kutskir, the solitary force behind Photopea, a free, web-based photo editing tool, has carved out a niche for himself in the competitive world of digital design tools. With over 500K daily users and a staggering annual revenue … Read more

7 Best Ways to Use Newline in an F-String

Problem Formulation In the following example, you use a newline character ‘\n’ inside the curly braces of an f-string: But if you run this code, Python raises a SyntaxError: f-string expression part cannot include a backslash. ⚑ The reason is that there is a limitation in versions of Python before 3.12 where backslashes are not … Read more

What Tech Career Would Fit Your Personality Type Based on Myers-Briggs’ 16 Personalities? (Online Tool)

The 16 Personalities refers to a modern adaptation of the Myers-Briggs Type Indicator (MBTI), which is a psychological tool that aims to categorize individuals into 16 distinct personality types based on four dichotomies: Let’s fool around with my interactive tool that cheekily predicts your tech destiny – because who doesn’t love a bit of fun … Read more

Get First N Google Search Results in Python (Official Way)

In this article, I’ll share my method of retrieving the first n Google search results for a given keyword and extract the text content from the resulting URLs. The search_google(query, num_results) function performs a search using the Google Custom Search JSON API, with the search query and the desired number of results (num_results) as parameters. … Read more

11 Profitable Ways to Make Money as a Prompt Engineer (2023)

In the US, 59.8 percent of the workforce are white collar workers. Most of them will eventually be disrupted by AI tools. Many of them can already be replaced by large language models as shown in recent research: This will release much of the work in our society and causes significant prosperity for society overall. … Read more

pip install unroll πŸ‘‰ Error Code 1: python setup.py egg_info βœ… Fixed

Problem Formulation If you try to install Python packages using pip, particularly the package “unroll”, you may encounter an error that halts the installation process. The error message displayed is: πŸ§‘β€πŸ’» Recap: Python setup.py – What’s This? Most Likely Solution: Upgrade Setuptools and Pip Ensuring that setuptools and pip are updated is crucial as outdated … Read more

What is setup.py?

I was just pondering on this question when working with a Python package. Let’s dive right in! πŸ‘‡ The Python file setup.py is pivotal for Python package creation, distribution, and management, ensuring that packages are easily installable and shareable within the Python community. In other words, it’s a script that contains information about a Python … Read more

Regex to Extract All Email Addresses from a String βœ… (Tutorial + Online Tool)

I have just created this small helper tool to extract all email addresses from a huge text file or string. Simply copy and paste your text into the field and click “Extract Emails“: πŸ‘‡ Email Extractor Enter Text: Extract Emails Copy to Clipboard Extracted Emails: JavaScript Regex In the online tool above, I used a … Read more

Python – How to Open a File by Regular Expression?

In Python, you can use the glob module’s glob.glob(pattern) function to find all the pathnames matching a specified pattern (e.g., ‘*.py’) according to the rules used by the Unix shell, which includes functionality for wildcard matching that can be used similarly to regular expressions for filename matching. Here’s a minimal example that filters out all … Read more