Wednesday, April 19, 2023

Python 3.11 - IntEnum str() representation changes

Got an unwanted surprise today trying to run my codebase ("TPMS Studio") using the latest Python (3.11) instead of the 3.7 / 3.8 combos I've been using for the past few years.

Turns out the core team made a breaking change to the behaviour of enums, which breaks our file format + causes the code to crash on startup (assert failures)!

The cause:
`str(eMyEnum.Value_1)` now evaluates to "1" instead of "eMyEnum.Value_1"

(Note: eMyEnum is defined as an IntEnum)


The solution I ended up with was based on:


[EDIT: This was the old solution. I have since learned of an even easier fix, from the official docs. See below]

In short, I now do something like:

import sys
import enum

if sys.version_info >= (3, 11):
    # Python 3.11+ hack
    class IntEnum(int, enum.Enum):
        # Get back old "EnumName.VariantName" str() behaviour
    # Use old defines for older Python versions
    IntEnum = enum.IntEnum



[Latest Update: This solution is easier to use. It comes from the official docs (i.e. example 2)]


from enum import Enum, IntEnum

class eMyEnum(IntEnum):

    __str__ = Enum.__str__      # <--- That's the key right there


 Reposting from my original Mastodon posts for easier searchability

Thursday, February 23, 2023

Thoughts on Urban Transit Infrastructure Design

Here are some personal observations of various urban/city design factors, and the relevant considerations. I'd drafted a few other versions of this in the past, but this one seems to fit the bill quite nicely (+ got finished), so this will be the one that goes up...

Inspired by this headline, here are some of my current thoughts on these matters:

* Most places reachable in < 10-15 mins, *by any means*  == Yes, agree that's the ideal scenario  (and is what life was like growing up here in Christchurch NZ). I've found that, especially for anywhere you need to go frequently, having to spend more than > 10 mins each time is quickly quite aggravating + draining.

In that light, the monster 40 min to 2.5 hr commutes that Americans frequently claim they have are therefore quite unfathomable. (Then again, maybe that's why there are so many messed up folk out there doing drugs and alcohol... again, things that never made sense)

* Many places reachable in ~10 min, but ONLY by walking / 2-wheeled contraption (and hailing a cab/Uber is not an option as distance too short for them to bother) == Personal hell. It's an annoying way to live... Grocery shopping is particularly aggravating (as you're limited to the 1-2 small bags you can reliably carry + manage to pack/unpack several times in a hurry)

Monday, February 6, 2023


A surprising insight I saw just yesterday for the first time, was when someone referred to Waitangi (aka "founding place of New Zealand in 1840" - see "Treaty of Waitangi" for details) as the "sad water place".

"Sad water place". If you think about it, and break down the meaning of the constituent parts of that name, that's actually what it means. "Wai" = water,  "tangi" = a event filled with sadness / mourning for the dead.

Hmm... The more you think about it, the more different meanings you can suddenly read into these things...  Oh the things you don't realise until much later - much like song lyrics, and finding old stuff from the past.

Thoughts on Plumbing and House Design

The past few months have been an (unwanted) deep dive into the world of household plumbing, and the various issues around it. Here are some things I've learned.

1) Debugging complex legacy plumbing and debugging complex legacy codebases are equally hard


2) At some point, you're going to need to check ALL the pipes


3) Most home designs make access to pipes HARD. Especially new/modern builds! 

For example:
    - Downpipe inspection panels hidden behind a wall. To access these, you must first drill + cut various wall panels to reveal the pipe, in order to find where the panel sits... then, when all is said and done, you then need to call in a builder, plasterer, and finally painter (complete with multiple rounds of sanding, phone calls, and time away from work/life waiting)

    - In contrast, older houses here at least have an underfloor crawl space, that can typically be accessed through some removable panel (similar to manhole covers). That said, in many cases, you end up needing to remove carpet to get to it, which does still mess things up a bit.


4) Some plumbers come better equipped than others. As a result, I've come up with a list of the neatest bits of equipment I've seen that IMO it'd be nice to have on hand, so they can do their jobs easier.  (see later) 

Tuesday, January 31, 2023

Useful AI Wishlist

 List of AI things would be actually worthwhile to pursue (instead of some of the junk that goes on):

* Earthquake Prediction. Not "forecasting" (i.e. vague regions + probabilities, over long periods). Prediction.

* Motion blur removal from single-shot, low resolution JPG's.

* Using content recognition to identify similar features across multiple content streams, for precise timestamp synchronisation.

* Removing rap vocals from music while keeping the general idea

Friday, January 27, 2023

National Airlines - 747 Freighter in Christchurch

Christchurch Airport had a welcome visitor today:  A 747-400 freighter from National Airlines!  And not just any one of the fleet, but N936CA - a bird painted in a striking red + white "30th Anniversary" livery!

Grey Warbler (Riroriro) - First successful photo

Came home today to the sound of a grey warbler (riroriro) sporadically singing away in a tree. Think I may have finally captured a photo of the elusive bird with the beautiful high-trilling song!

Playing with the exposure, it becomes clear that it has stunning red eyes, confirming its identity. Luckily, everything came together to make this happen today!


Sunday, January 15, 2023

Juvenile Silvereyes

Wheee! This afternoon, I came home to the sound of juvenile silvereyes excitedly crying for food. I rushed inside, mounted the bird lens, and looked up at the tree armed with some proper gear. I'm glad I did, as it turns out there were 3 of them in an adorable huddle, and not just the single fat one I thought I'd seen earlier!  😊

3 adorable fluffy juvenile silvereyes

Cross posted for archival purposes from Mastodon

Friday, November 4, 2022

VMWare - Getting copy-paste support working

While doing some work in a VM today, I discovered, much to my chagrin that VMware was not allowing me to copy text from the VM back out into the host machine! As can be imagined, this is a massive pain if you're trying to Google a frustrating error message, or even to extract the error logs to file bug reports.

The method I'm reposting here has been tested to work with "VMware Workstation 16 Player" (16.1.0 build-17198959) on Windows 10. I'm reposting it here mainly so that I can find it again easier the next time this breaks, but also since the original post may end up going away (given that shabby state of the forum it's hosted on).


Original Link (by "pyhoff")



1) Ensure the VM isn't running

2) Locate the "Virtual Machines" folder. It should be under your Home Directory / Documents folder.

3) Navigate to the VM in question

4) Open up the ".vmx" file in a text editor

5) Add whichever of the following defines are missing from that file  (I just added all of them): = "FALSE" = "FALSE" = "FALSE" = "FALSE"

6) Save the file and start the VM again

7) Bi-directional copy and paste should now be working.

Tuesday, September 20, 2022

The Queen's Funeral

The droning sound of the solemn funeral march music, bells tolling, and the glum faces of everyone - the elderly royals in particular - taking part in the arduous funeral procession as it slowly trundled back and forth was quite a sight to behold (especially watching the processing turning corners - wow... that's a thing of beauty). A very very sad moment in time is the most fitting way to describe it.

Friday, September 9, 2022

On QE II's Passing

London Bridge is Down.

This morning, I awoke to news that Queen Elizabeth II had indeed passed away overnight, bringing to a close an incredible era - spanning the first successful ascent of Mount Everest, man stepping foot on the moon, the invention of the Internet, the birth of yours truly, the founding and rise of Blender, and in recent years, COVID.

Late last night, the news broke that the Queen's health had taken a turn for the worst, and that members of the Royal Family were urgently cancelling appointments and rushing to Scotland. If ever there was a clearer sign that the end was in sight, there could be no mistaking what this all meant. (*1)

Just like on the day I learned that my Grandma had died - again on a regular day in September - I can tell you the piece of code / chunk of functionality I was working on when I first heard the news. In the case of my Grandma, it was the Edit Mode curve vertex selection code - specifically, either the select next/prev, select first/last, or select nth operators. That afternoon, I'd been working on trying to get to the bottom of a series of annoying crashes in my initial implementation of those features. From memory, I think I managed to fix at least one of those, though my memory is a bit hazy now - all I remember is that after receiving the phone call, my hands went cold, and I rather hastily proceeded to quickly wrap off the bit I'd been doing, and shut down my computer.

Last night, I'd instead by trying to get working an "inline popup panel UI" for editing a CSG Node Tree (used to avoid needing switching modes / editing contexts) - my initial attempt of putting this UI in a separate window had turned out to be a massive failure, resulting in a mix of random untraceable crashes (i.e. it was deep in the bowels of the C++ / QML engine perhaps, and not inspectable from my  code) and/or more predictable yet still utterly frustrating "polish()" loop errors when the popover panels launched from buttons within that UI would run out of space to be fully displayed without cropping. In the end, I finally resolved to rip out that approach, and all back on putting the whole panel inside a popover panel instead. Doing so would hopefully bypass all the polish() loop and related issues (there was ample window-space to draw in now), at the expense of having a UI formed from nested-popups-upon-popups, and without the ability to reposition + resize those popups (not that the dialog was fully resizeable either for that matter though). In this case though, I did finally manage to get the beast working before clocking out for the night, all the while checking various twitter feeds to check if the inevitable had happened.

While the two events are not really comparable - one was after all the head of state for multiple countries - and regardless of whatever wokey-pokey convictions you may hold about the role of monarchy in the 21st century, I think it's only right and appropriate that we to spend a few moments reflecting on the life and times of one of the world's most loved and respected "grandmas", a stable and ever-present constant pillar in a rapidly changing world.

Thank you for your many decades of service Your Majesty. Rest in Peace.


Saturday, May 21, 2022

Saturday Photowalk - Recent changes around the Arts Centre...

With fine sunny weather today (sandwiched between two days of chilly, showery, wintery weather) it was a great day to get out and about, and away from my desk for a few hours. It ended up being a nice afternoon to take a walk around the Arts Centre for the first time in ages - between the first wave of Omicron, and our very own "Camp Covid" from the rabid "Freedumbs" crowd just around the corner, it's been a while since I've been to this part of town. 


Here are some highlights from the afternoon. Unfortunately, I only had my phone with me today, though things turned out relatively ok in the end I guess...