zerosleeps

Since 2010

Reading log for 2023

As is tradition around here, my reading log review for 2023 is in. Continuing the downward trend I completed just 20 books last year, and abandoned an additional 3.

The average rating of the completed books was 3.3 out of 5. I didn’t discover any new 5-stars this year - the 4 books that I gave 5-stars to were all re-reads.

If I exclude re-reads, the average rating drops to 2.8. 3 stars is a “pass” in my rating systems, so 😬

I’m really not good at discovering new authors/genres/whatever, and I’m convinced that’s what puts me off picking up the next book.

Non-fiction scores much higher than fiction, so maybe this year I’ll focus more on non-fiction and see if that helps. Having said that, I fully intend to start the year by re-reading some of my favourites - “The Martian”, “Project Hail Mary”, and maybe “To Obama”.

Errors in Kindle books

The book I’ve just finished reading on Kindle had at least two occurrences of the string “'” instead of actual apostrophes. How does that happen? Obviously I know how it happens, but I don’t understand how it makes it into my hands like that. And this was a publication from 5+ years ago - how has it not been fixed?!

In my experience it’s fairly common to encounter weirdness in Kindle books. It’s usually layout things, where words are hyphenated in the middle of a line, or what should be one line is rendered as 5 lines with a couple of words each.

I don’t remember ever seeing such oddities in printed books. I’d have thought digital books would be easy peasy to get right, and the labour required to lay out a printed book would lead to mistakes. Shows what I know!

Updated Sublime Text timestamp command

After my last post I was looking through some of my own uses of Python’s datetime module, and one of the things I uncovered was a Sublime Text command I created years ago and have blogged about before. I don’t know what I was thinking when I originally created the class. Is that Python 2 code? No idea.

Here’s my current version of that same module:

import sublime_plugin
import datetime


class Rfc3339DateCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.date.today().isoformat()
        )


class Rfc3339DateTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.datetime.now().astimezone().isoformat(timespec="seconds"),
        )


class Rfc3339DateTimeUtcCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(
            edit,
            self.view.sel()[0].begin(),
            datetime.datetime.now(datetime.timezone.utc).isoformat(timespec="seconds"),
        )

(datetime.UTC has been an alias for datetime.timezone.utc since Python 3.11, but the current version of Sublime Text uses Python 3.8 at the time of writing this.)

When paired with appropriate entries in a .sublime-commands file these three functions insert something like the following respectively:

2023-11-24
2023-11-24T14:03:58+11:00
2023-11-24T03:03:58+00:00

datetime.utcnow() is now deprecated

Miguel Grinberg with a nice article about the deprecation of Python’s datetime.datetime utcnow() and utcfromtimestamp() functions.

I discovered the article via this post on Hacker News which has a really great discussion about the topic.

The core Python developers are stuck between a rock and a hard place on this one. If it was up to me I’d be updating these functions to return aware datetime objects. It’s obvious that utcnow() should return a UTC datetime object, right?

But it’s a good job it’s not up to me, because this standard library is almost certainly used by millions of Python scripts! How on earth do you change something like that without upsetting a lot of people? You can’t throw deprecation warnings for a while and then change the functions - you’ve got to remove them. The things using these functions have to fail loudly.

Naming things is hard.

Sleazy pricing

Screenshot from petbarn.com.au

Quick. How much is one bag of kitty litter from Petbarn?

There are seven dollar-amounts on that one product card. The price for a regular human is one of the hardest to read: thin grey font on a coloured background.

Call me old and grumpy, but shit like this makes me shop elsewhere and never look back.