Saturday, 22 March 2025

It's always worth checking

I was writing some Python code today, and I had some logic best served by a case statement.  I remembered that Python doesn't have a case statement, but I decided to google to see if there was a suitably pythonic pattern I should use instead.

Aha!  Python v3.10 introduced a case statement, and I'm currently using v3.13.  Excellent.  I scanned the syntax, then added the relevant lines to my code.

After I'd finished that bit of coding, I went and read the official Python tutorial.  Of course, Python being Python, its 'case' statement is actually a very sophisticated and powerful 'structural pattern matching' statement.  I might have some fun with this...

So, every day in every way, at least Python is getting better and better.




No comments:

Post a Comment