Month: September 2019

1.1 Million USD — How Much You Are Worth as an Average Python Coder?

Have you ever calculated your market value as a Python developer? When estimating the value of a company, analysts often use multiples of its yearly earnings. Let’s take this approach to come up with a rough estimate of how much your Python skills are worth. Say, we are taking a low multiple of 10x of …

1.1 Million USD — How Much You Are Worth as an Average Python Coder? Read More »

Why Does the Scikit-learn Library use a Trailing Underscore Convention for Attribute Names?

If you’ve used the sklearn library in your own code, you may have realized that all attributes are suffixed with a trailing underscore. Here’s an example for the k-means algorithm: In the second-last line, we used the kmeans attribute cluster_centers_. Why does sklearn library not use the attribute name cluster_centers? ‘The short answer is, the …

Why Does the Scikit-learn Library use a Trailing Underscore Convention for Attribute Names? Read More »

What’s the Best Way to Format Python (White Space, Comments, etc.)?

You should style your code according to the PEP 8 standard which was co-authored by Python’s creator Guido van Rossum. It has very high credibility and Python coders all around the world follow this style guide. However, the style guide is quite lengthy and boring to read. I would rather recommend that you use an …

What’s the Best Way to Format Python (White Space, Comments, etc.)? Read More »

A List of Lambda Functions? This Python Puzzle May Surprise You…

Guido doesn’t like lambda functions too much. Yet, most large code projects contain a lot of them! (Many coders use lambda functions as GUI callbacks, etc.) In this “Coffee Break Python” email series, we take a pragmatic approach regarding Python code style — living in the “is” rather than in the “should be” world. Can …

A List of Lambda Functions? This Python Puzzle May Surprise You… Read More »

Decimal: Python’s Float Trap and How to Solve it

You may know the following surprising code snippet: The following explanation is from the puzzle-based learning Python workbook: This puzzle performs a simple arithmetic computation adding together the float value 0.1. The question seems to be very simple—but as we’ll see in a moment, it’s not simple at all. Your inner voice is wrong. And …

Decimal: Python’s Float Trap and How to Solve it Read More »

How to Warn Users Before They Attempt to Close a Browser Tab in JavaScript?

To prevent data loss, do you want to create the following warning popup (alert) before a user of your web page attempts to close, reload, or leave the page via the “back” button? You can do this in a simple step: just copy and paste the following JavaScript code snippet between the <head> … </head> …

How to Warn Users Before They Attempt to Close a Browser Tab in JavaScript? Read More »

Your Python Code Sucks

Does your code always follow the PEP standard?Have you ever been criticized for not writing “Pythonic code”? I know I have — especially when I was just starting out with Python a few years ago. This can be frustrating because criticism is not always constructive. Destructive criticism kills any motivation there is left for you …

Your Python Code Sucks Read More »