Archive for February, 2008

Ruby-like expression substitution in Python

February 28, 2008

I don’t know much Ruby, and probably won’t learn; all that syntax and magic scare me away. But I have to admit it has some darned useful gadgets. Here’s a python function I hacked up to do something much like Ruby’s expression-substitution, using the same #{ } syntax. It doesn’t allow curly braces inside the #{ }; were I a little less lazy I would put in some escaping.

import re
import sys

def esub(s):
    Perform Ruby-like expression substitution.

    >>> x=3
    >>> y='A'
    >>> esub('abc#{x}def#{3+5}hij#{"".join([y, y])}')
    restr = r'(?:#{(?P[^{}]*)})|(?:[^#])+|#'
    fr = sys._getframe(1)
    def process(m):
        txt ='exp')
        if txt is not None:
            val = eval(txt, fr.f_globals, fr.f_locals)
            return type(s)(val)
    return ''.join(process(m) for m in re.finditer(restr, s))

Best Hillary Impersonation Ever

February 28, 2008

I am generally predisposed in favor of anything done by attractive blondes, but even accounting for that I think Rosemary Watson‘s Hillary Clinton is outstanding. Alas, it may be less relevant soon. I doubt she does such a good Obama…

Metropolitan, and Mansfield Park

February 22, 2008

We saw Metropolitan last night; my first Whit Stillman film. Rich (and one not-rich) preppy college students are home in Manhattan for Christmas break, they go to debutante parties and after-parties; they talk at great length and with great pretension and wit; not much happens. It’s one of those low-budget indie films that makes me like low budget indie films. The (Oscar-nominated) script struck me as stilted but at the same time so witty and engaging I didn’t care. The acting was (with one exception, see below) was, well, the acting of indie film actors-still-learning-to-act, most of whom (AFAICT) have done little since, but again, they were all endearing enough that I liked them anyway: the very sweet Carolyn Farina especially grew on me. The score was fabulously perfect.

Allegedly (that is, according to some random person who said so on the IMDB) it’s a “loose adaptation” of Mansfield Park. Really it’s not at all, except in a sort of vague thematic way, in that both are about manners and morals and why they’re important. And the heroine was rather a Fanny Price. Indeed, Carolyn Farina was a much better (at least in terms of being faithful to the book) Fanny than either of the two in the actual adaptations I saw recently–Frances O’Connor is a fine actress, but her Fanny bore little resemblance to Jane Austen’s.

And there is a great discussion of Mansfield Park in the movie, in which our hero eventually reveals that he formed his opinion of it based only on a Lionel Trilling essay, and sees no need to read the book itself; it ends:

Audrey Rouget: What Jane Austen novels have you read?

Tom Townsend: None. I don’t read novels. I prefer good literary criticism. That way you get both the novelists’ ideas as well as the critics’ thinking. With fiction I can never forget that none of it really happened, that it’s all just made up by the author.

The lone really good actor I mentioned above was Chris Eigeman, whom I had previously seen mostly as Mr. Herkabe, Malcolm in the Middle‘s hilariously evil teacher. In Metropolitan he’s just as witty and smart and pretentious and funny, just not evil. I was also thought he looked frighteningly like Frankie Muniz. Mr. Herkabe is supposed to be sort of a bitter and burned-out older Malcolm, so I suppose it makes a certain kind of sense. I wonder if that had anything to do with his casting?

Fun with voting

February 20, 2008

Speaking of the stupid ways we run our elections, I just saw this review of Gaming the Vote, about the stupid ways we run our elections.  I’ll try to read the actual book sometime soonish.

I do like the idea of Range Voting–I certainly don’t think it could be any worse than what we have now.  As far as I know it avoids most of the pathologies of our current plurality system (even with a pure popular vote, not worrying about the monkeywrenches due to the electoral college and whatnot), and the results are simple to understand and “obviously fair,” unlike, say, Condorcet voting and Borda count (which have problems of their own).

I think I like Approval Voting–a special case of Range Voting–even more.  I would expect it to produce generally similar results to Approval Voting when there are lots of voters (although says not); and it’s much simpler.  Arrow’s Theorem doesn’t apply to either, as they are not based on pure preference orders.


February 20, 2008

Having heard this on the radio the other day, I now think that the superdelegate system, and the alleged conundrum the poor things may face, is even sillier than I had thought.

First off, the Obaminators’ argument that the superdelegates should vote The Will of the People is obviously boneheaded (setting aside the obvious fact that the Obama camp would immediately say otherwise if he weren’t ahead in inferiordelegates).  If they were supposed to be rubber stamps, there would really be no point in having them at all; and indeed they were originally created to provide “leadership” in close cases.  Given the “leadership” the Democrats in Congress have shown the last few years, it’s hardly surprising that they’re desperately trying not to show any now.  (I find myself reminded of the GE Followship Award from 30 Rock.)
And beyond that, if the tallies are close enough that the superdelegates can matter, then really there’s no Will of the People to follow–the difference in the two would be within the margin of error of our ridiculous primary/caucus system, in comparison with which the Electoral College looks positively sane.  The superdelegates were a stupid solution to a stupid problem, and it shouldn’t be a surprise that they seem a bit problematic now.  Remember that the only time they’ve mattered before, the result was Walter Mondale.

Historians on the Second Amendment, cont.

February 13, 2008

I’ve read, or rather skimmed slightly more thoroughly than previously, the two aforementioned historians’ briefs in DC v Heller. And I revise more former pro-DC-side judgment: my sympathies are now with neither.

What struck me most was how similar the bulk of the two briefs were. Both discuss at length the history of the second amendment and its antecedents in the context of the lively discussion of militias and standing armies; lots of good detail in both. They “merely” draw different conclusions from that context: one that the second amendment guarantees that the federal government could not allow the militias to languish unarmed or underarmed, the other that the second amendment guarantees an individual right as a mechanism to an end (the militias again), and that the right survives even if the purpose does not. (I am of course oversimplifying, especially as regards the pro-gun brief, which also discusses “bearing arms” as a civic virtue. And I’m sure I’m missing important points).

I draw neither conclusion; as I’ve said before I think the result of the history is an interpretive mess. For at least two reasons: first, the fact that the major premise in the militia cluase no longer holds (decided, as some wag noted, in the case of North v South, 1865); and second, that the actual text was the result of much discussion and compromise–I have to assume that the Framers were no more unified in their views of the particulars of the 2A as any set of politicians are on anything, and the records cited by both briefs seem to me to support that. The current discussion of individual versus collective rights is, in my view, at best a feeble attempt to make sense of the history, and at worst an impediment to understanding it.

McCain and conservative pundits

February 13, 2008

From the Funny ‘Cause It’s True dept: The Onion on why conservative pundits hate McCain.

Speaking of McCain: based on 10 seconds of research inspired by this article in Slate, Meghan McCain is cooler than Chelsea Clinton.

Historians on the Second Amendment

February 12, 2008

Among lots and lots and lots of amici briefs in DC v Heller are “pro-individual-rights” and “pro-militia-interpretation” briefs from opposing sets of historians. Haven’t read them yet, but they look interesting. From what little I’ve skimmed, my sympathies are with the militia one, not surprisingly.  A couple of quotes:

As a problem for constitutional historians, the question can be elaborated and restated in this way: Did the framers and ratifiers of the Amendment believe they were constitutionally entrenching an individual right to keep arms for personal protection? Or did they conceive the Amendment to achieve a different end, by affirming that a “well-regulated militia” of citizen-soldiers would preserve “the security of a free state,” principally by lessening the need for a republican government to depend on a standing army?

What is at dispute is whether legal rights of private ownership were what the Second Amendment constitutionally entrenched. During this period, Americans were hardly shy about identifying and discussing such fundamental rights as representation, trial by jury, or freedom of conscience, or the natural rights to life, liberty, and property. The fact that references to the keeping of firearms are so few and terse, or that the modern academic controversy over the Second Amendment has been forced to squeeze so much modern interpretive blood from so few evidentiary turnips, is itself an indicator of how minor a question this was at the time. The same cannot be said about the role of the militia in the constitutional order. That was the subject that was patently in dispute in 1787-1789, and that is why the exceptional preamble to the Second Amendment is a true guide to its original meaning.

Preludes from Parthenia

February 12, 2008

I transcribed a couple of pieces from Parthenia this weekend. The Bull is a particularly neat little thing; I like the way it can’t decide whether it’s major or mixolydian (if I’m using those terms more or less correctly).

Dr Bull, by the way, seems to have been a bit of a Jack-the-Lad, frequently in trouble for adultery, presumably with unwisely chosen women. He looks decidedly Satanic in the wonderful painting at the wikipedia article.


February 12, 2008

Speaking of Alessandro Nivola and Embeth Davidtz, they also starred (emphatically not as siblings) in Junebug, one of my favorite movies. Most movies about the south are silly caricatures or grotesques (sometimes extreme grotesques) or generally uninterested in reality (not that there’s anything wrong with that; Deliverance and O Brother Where Art Thou are great movies). Junebug is a rare exception.

Quick summary: Davidtz plays a cosmopolitan art dealer specializing in “outsider art,” newly married to Nivola; they pay a visit to his North Carolina home, both so she can meet his family and try to cut a deal with a nearby artist. She finds herself completely out of her element: she doesn’t understand the culture; her mother-in-law resents her; she finds she knows her husband less well than she thought.  And she doesn’t know quite how to deal with Nivola’s sweet and naive sister-in-law (the wonderful Amy Adams), who adores her as representing all that is exotic and sophisticated.

Much in Junebug resonated with me.  I love the way Nivola reverts to being a kid at home and clams up completely (thus providing no help to his wife); I do that too.  The town reminds me of my own hometown; the culture is subtly different from, say, towns in Massachusetts in ways I’d be hard-pressed to describe.  Nivola’s father, searching for a lost screwdriver, says to himself, “Now where would I be if I were a screwdriver?”–and opens the refrigerator.