George V. Reilly

Python: Import subclass from dynamic path

I needed to import some plugin code written in Python from a directory whose path isn’t known until runtime. Further, I needed a class object that was a subclass of the plugin base class.

from somewhere import PluginBase

class SomePlugin(PluginBase):
    def f1(self): ...
    def f2(self): ...

You can use the imp module to actually load the module from impl_dir. Note that impl_dir needs to be tem­porar­i­ly prepended to sys.path. Then you can find the plugin subclass using dir and issubclass.

import os, imp

def import_class(implementation_filename, base_class):
    impl_dir, impl_filename = os.path.split(implementation_filename)
    module_name, _ = os.path.splitext(impl_filename)

    try:
 
continue.

Asking for Help

It’s better to stay calm when things aren’t going well. Stress and panic are contagious. When you’re broad­cast­ing stress or panic on all channels, other people start picking it up. If you can keep your cool, others are more likely to remain calm too. Often that’s for the best, but sometimes it backfires because others in­cor­rect­ly believe that everything is still okay.

Knowing when to ask for help is an art. You learn a lot when you persevere and try different things, many of which may fail. The failures will likely show you where your un­der­stand­ing is deficient; you learn some of the many ways in which things can go wrong. If you throw continue.

Toastmasters Speech Contest

I mentioned a few weeks ago that I was going to be the Contest Chair for the In­ter­na­tion­al Speech and Evaluation Contests at Freely Speaking Toast­mas­ters. Those contests were tonight, and I was both Contest Chair and Toast­mas­ter. The contest chair sets up everything be­fore­hand; the toast­mas­ter runs the contest itself; frequently but not nec­es­sar­i­ly the contest chair is also the toast­mas­ter.

I’m happy with how it came off. I managed to recruit two speakers for the Speech contest and three evaluators for the Evaluation contest, all of whom acquitted themselves well. I also recruited three judges, two ballot counters, one timer, a sergeant at arms, and a test speaker to make the contest run. The continue.

Adapting Books for Film and TV

I came across this cartoon today; it reminded me that I’ve been meaning to write about the hit-or-miss nature of adapting books for the screen.

Books and video/film are different media, with different con­ven­tions and needs. Often the most-loved elements of a book are lost when it’s adapted for television or film, upsetting fans.

As J.K. Rowling wrote about one of the Harry Potter movies:

"It is simply impossible to in­cor­po­rate every one of my storylines into a film that has to be kept under four hours long. Obviously films have re­stric­tions – novels do not have con­straints of time and budget; I can create dazzling effects relying on nothing but the in­ter­ac­tion of my own and continue.

Keybase

I was sent an invite to Keybase a few weeks, which I accepted tonight.

Keybase Wants To Make Serious Encryption Accessible To Mere Mortals explains:

From a cryp­to­graph­ic standpoint, PGP is rock solid. In practice, using it is very messy. Its complexity has deterred the vast majority of people who might otherwise benefit from using encryption.

The first problem is es­tab­lish­ing a valid identity, especially with other people located oceans away. The second is dis­trib­ut­ing public keys without nefarious types posting al­ter­na­tive keys that appear to be registered to the same person. … The third issue is getting people to install and use PGP software.

I can now be reached via https://keybase.io/georgevreil­ly. I’ve proved my identity on GeorgeVReil­ly.com, GitHub, continue.

Review: Run Fatboy Run

Run Fatboy Run is a Simon Pegg comedy from 2007, which we just watched. I didn’t have high hopes for it and it was better than I expected. Dennis left a pregnant Libby (Thandie Newton) at the altar five years ago. Now he’s an overweight security guard in a London lingerie shop and she’s found a new boyfriend who’s everything that Dennis is not: Whit (Hank Azaria) is well off, handsome, and very fit. Somehow Dennis ends up promising to run in a marathon in three weeks’ time that Whit is also running in. Much of the story revolves around his training, his desperate attempts to win over Libby, and continue.

Review: Hail, Caesar!

The Coen Brothers’ latest movie, Hail, Caesar!, is a lot of fun. I’ve been looking forward to it since the trailers showed up a few months ago. It’s a homage to the Golden Age of Hollywood, an age where quirky talents like the Coens could not have made Coen Brothers’ movies. We see song and dance numbers, syn­chro­nized swimming, singing cowboys, and ballroom dramas. Most of all, we see a big-budget swords-and-sandals epic, whose star, Baird Whitlock, has been kidnapped by The Future, a group of Communist screen­writ­ers, and is being held for $100,000 ransom. Eddie Mannix is the studio fixer who has to wrangle the studio’s stars and keep them out continue.

Taibbi on Trump

In a new article for Rolling Stone, Matt Taibbi excoriates Trump:

It turns out we let our electoral process devolve into something so fake and dys­func­tion­al that any half-bright con man with the stones to try it could walk right through the front door and tear it to shreds on the first go.

And Trump is no half-bright con man, either. He’s way better than average.

Both Trump and Cruz scare me, for very different reasons. Trump is impulsive, all id, doesn’t give a fuck, riling up the worst impulses of the American electorate for short-term gain. Who knows what this loose cannon will do? Cruz is a nasty piece of work, cold and cal­cu­lat­ing, a hard-right continue.

Rome the Eternal City Video

I just watched an in­ter­est­ing video that recreates Rome as it probably was circa 320 AD. At that point, Rome’s population was somewhere between one and two million people, the largest city in Europe until 19th century London. Con­stan­tine was Emperor and a few years later, he would move his capital to Con­stan­tino­ple. A century and a half later, the final emperors would die.

I’ve only visited Rome once, when I was ten years old. I’m long overdue for another visit.

Review: Graveyard Dust

Title: Graveyard Dust
Author: Barbara Hambly
Rating: ★ ★ ★ ★
Publisher: Bantam
Copyright: 1999
Pages: 315
Keywords: historical mystery
Reading period: 21 February, 2016

New Orleans, 1834. Benjamin January is a free man of color and a Paris-trained surgeon who must support himself as a musician. His sister Olympe, a voodooi­enne, and another woman, Célie, are accused of murdering Célie’s husband, and Ben must save them from hanging. As a pro­fes­sion­al musician and a colored man, Ben moves between the high society of the old French in­hab­i­tants and the new American merchants, the poor white areas of town, the many slaves, and the small free black middle class. Hambly adeptly explores slavery, the uneasy crossover between French and American continue.

Previous » « Next