Chris

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students. To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He's author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.

Why Does “pip search” Lead to an ERROR: XMLRPC request failed?

Today, when trying to get some information about specific pip packages, I wanted to use the pip search command in my local computer’s PowerShell. pip search Here’s the syntax: py -m pip search [options] <query> The semantics of pip search is to find PyPI packages that contain the <query> in their package name. Error Message …

Why Does “pip search” Lead to an ERROR: XMLRPC request failed? Read More »

dir() versus __dir__() – What’s the Difference?

Problem Formulation What’s the difference between the built-in dir() function and __dir__ dunder method in Python? Quick Answer Python’s built-in function dir(object) returns a list of the object’s attribute names and method names. The dir() function is a wrapper around the __dir__() method because it internally calls the object’s dunder method object.__dir__(). But the two …

dir() versus __dir__() – What’s the Difference? Read More »

How to Convert a String to a Dictionary in Python?

Problem Formulation Given a string representation of a dictionary. How to convert it to a dictionary? Input: ‘{“1”: “hi”, “2”: “alice”, “3”: “python”}’ Output: {‘a’: 1, ‘b’: 2, ‘c’: 3} Method 1: eval() The built-in eval() function takes a string argument, parses it as if it was a code expression, and evaluates the expression. If …

How to Convert a String to a Dictionary in Python? Read More »

How to Convert a Unicode String to a Dictionary in Python?

Problem Formulation Given a Unicode string representation of a dictionary. How to convert it to a dictionary? Input: u”{‘a’: 1, ‘b’: 2, ‘c’: 3}” Output: {‘a’: 1, ‘b’: 2, ‘c’: 3} Note: The u’string’ representation represents a Unicode string that was introduced in Python 3. This is redundant as all strings in Python 3 are …

How to Convert a Unicode String to a Dictionary in Python? Read More »

Python List of Dunder Methods

When searching for a list of dunder methods, I only found a couple of resources all over the web—each covering only a fraction of dunder methods. So, here’s my collection of 127 dunder methods (also called “magic methods”) from those sources, sorted alphabetically: __abs__ __add__ __aenter__ __aexit__ __aiter__ __and__ __anext__ __await__ __bool__ __bytes__ __call__ __ceil__ …

Python List of Dunder Methods Read More »

Python Version Backward Compatibility

The Python language does not generally provide backward compatibility. The ability to break inefficiencies and fix wrong design choices are major reasons why Python has remained lean and efficient over the last decades. However, the PEP 387 standard discusses that incompatibility issues should be well thought out. Here’s the basic policy when backward incompatibilities may …

Python Version Backward Compatibility Read More »