Almost exactly what I was looking for -- thank you!
Unfortunately, I still don't know how to prevent WordPress from stripping class tags from my
<pre> links, when I post from MarsEdit.
The MarsEdit forums provide a solution:
the "class" attribute is not allowed by default with the "kses.php" file in WordPress. I guess after editing that file and allowing class as an allowed attribute, it is working fine.
Indeed, it is:
for i in range(10): print("Mon Dieux, it works!")