I mostly write about programming in Python (and sometimes, Julia) for Data Visualization and Data Science but occasionally I stray into other areas of science and technology.
If you’d like to know when I publish new articles, please consider subscribing to my free, occasional, newsletter here.
You can download the code for several articles from my Github page.
Python has, at long last, got itself a switch statement. Hooray!
But it’s not your common or garden switch statement as you would find in C or Java — of course not, this is Python. Python 3.10 implements Structural Pattern Matching which can be as simple as a switch statement but can also be rather more.
I covered the basics of Structural Pattern Matching here — this article goes into the topic a bit further, looking at capturing matched patterns (getting the value of a match that could be more than one value) and adding conditions to patterns.
Python 3.10 has implemented the switch statement — sort of. The switch statement in other languages such as C or Java does a simple value match on a variable and executes code depending on that value.
It can be used as a simple switch statement but is capable of much more.
That might be good enough for C but this is Python, and Python 3.10 implements a much more powerful and flexible construct called Structural Pattern Matching. It can be used as a simple switch statement but is capable of much more.
Let’s take the simple switch case. Below is…
You could choose a language by going to the Stackoverflow survey website, find the highest paid language and learn that.
It’s a strategy. But not necessarily a good one.
For interest, here are the salaries reported by the Stackoverflow Developer’s Survey, 2020.
Sentiment Analysis is not an exact science. Natuaral language is full of strange expressions, words that mean more than one thing, idioms, sarcasm and any number of things that make the extraction of meaning difficult. Look at the these two sentences.
“I know why I keep making the same mistakes — I don’t think!”
“Sentiment Analysis is accurate in all circumstances — I don’t think!”
In the first sentence the phrase “I don’t think” explains the first part of the sentence but in the second it is sarcastic and negates the meaning of the preceding part of the sentence. …
If you want to publish a novel or a textbook, you can do this through commercial outlets like Amazon’s KDP, Barnes and Noble Press or Rakuten Kobo. But this is not really an appropriate route for smaller documents or articles.
So, what if you want to reward your patrons with extra downloadable content, or make a short compilation of previous work for your faithful followers, or even sell short-form content from your website or online store? …
It may seem as if I have something against Dash. Honestly, I haven’t; it’s a fine product, comes with a lot of support from Plotly and does what it is intended to do, well.
But, as I attempted to demonstrate in a previous article, there is no need to write HTML in Python (as Dash requires you to do) when you can write it in HTML! …
Why would you want to write HTML in Python? It baffles me. But that is what you need to do if you want to write a Dash app.
While I understand that there is a certain amount of satisfaction in having all your code in a single file, it seems to me that if you know enough about HTML to code it in a different language then you certainly know enough to write it in HTML!
I’d love for Dash to be the solution to writing web visualization apps but I’m not convinced.
Consider the following:
Flask is a web application micro-framework which means it is a very lightweight library for developing web apps. Creating your first Flask app is easy but first you will need to install it with pip or conda, for example:
pip3 install flask
Next, open a new directory and create a file app.py with the following code:
from flask import Flaskapp = Flask(__name__)@app.route(‘/’)
The code is pretty straightforward. The first line imports the Flask library; the second creates a Flask object (that will be run); and the rest of it defines a route. A route…
When Buzz Aldrin guided himself, and Neil Armstrong, to the surface of the moon on July, 20th, 1969, he was aided by a computer that was the first such device built with integrated circuits and, unsurprisingly, was the state of the art at the time.
That was over 50 years ago, so of course, you would expect computers to have got better. But how much? Ten times more powerful, 100 times, a 1000 times, perhaps. Maybe you’d be surprised to know that the smartphone in your pocket is 100,000 times more powerful than Aldrin’s computer.