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.

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 »

How to Check the Python Version at Runtime?

Method 1: sys.version To check your version at runtime in your code, import the sys module and print the sys.version attribute to your Python shell: Method 2: sys.version_info If you need an easy-to-process output for the major, minor, and micro versions, use the sys.version_info attribute. For example, Python version 3.9.5 has major version 3, minor …

How to Check the Python Version at Runtime? Read More »