Reconstructing a module from a Python bytecode cache file
So, sometimes you lose your configuration files and they happen to have a .pyc version that still exists.
>>> import marshal >>> f = open("imgapi/conf.pyc") >>> f.seek(8) >>> o = marshal.load(f) >>> o <code object <module> at 0x7f84ff7f8c60, file ".../imgapi/conf.py", line 1> >>> dis.dis(o) 1 0 LOAD_CONST 0 (-1) 3 LOAD_CONST 1 (('*',)) 6 IMPORT_NAME 0 (imgapi.conf_defaults) 9 IMPORT_STAR 2 10 LOAD_CONST 2 ('gevent') 13 STORE_NAME 1 (url_fetcher) 3 16 LOAD_CONST 6 (('.yo-toad.se:8000', '.yo-dev.se')) 19 STORE_NAME 2 (rewrite_host) 22 LOAD_CONST 5 (None) 25 RETURN_VALUE >>>
And from this, one can see what this (rather short) configuration file used to say:
from imgapi.conf_defaults import * url_fetcher = "gevent" rewrite_host = (".yo-toad.se:8000", ".yo-dev.se")
Now for some delicious food.
This might seem silly: git pull
So, as a bilingual person, you very often borrow terms from one language into the other. Examples include how Swedish developers will say "libbet" for "the library", but crucially, only for software libraries.
The very reason we bilingualists borrow words so often is that we feel the non-native word is a narrower metaphor for what we're trying to say.
This happens for pretty much any IT-related verb, I say "Jag pushar branchen till ditt repo" where neither push, branch nor repo are actual Swedish words. ("I push the branch to your repository".)
Why is this a problem, and why do I bother telling you about it? It surely is a natural phenomenon for any bilingualist, and not anything new or unheard of.
It's a problem because of the word "pull". See, Swedish has a particular suffix for verbs in present tense. It's "-a". This, applied to "pull", yields "pulla".
The word "pulla" already exists, which is usually not an issue, were it not for what the word means: "pulla" is colloquial Swedish for "female masturbation", or "fingering oneself".
So, to me, the following conversation I had with a fellow Swedish coworker the other day makes total sense (and you can probably guess what it means):
me: okej, najsme: även om du pullat?coworker: pullade för ~5min sen
I ask if he has pulled the latest changes, he says he pulled me five minutes ago. Nothing odd about that. Except that this, interpreted by an average Swedish person, reads:
me: okay, niceme: even if you fingered yourself?coworker: I fingered myself about five minutes ago
You can see how this can get pretty awkward when around people who have no idea about these matters, as is not uncommon.
So please, dear reader, I call upon you to change this name to something more bilingually friendly. Something neutral.
A little off-topic
Oh man, this one's great.
On branching... Wait no, on committing
So, mr. Bennett is causing a ruckus as always, discussing the benefits of Hg over Git.
While I heartily agree that Git branches are sort of a stretch of the implementation to match the metaphor, and I'm sure Hg does it way better (I've used Hg but I use Git much more often.)
However, Git has one feature that just makes it so much better: the staging area.
Coincidentally, the staging area seems to confuse many new users (and Hg users for sure) -- in essence, it's what you're preparing to commit. I don't really care much for Git branches (I just know they're easy to merge, and merges do preserve history).
What it lets you do, and what Git is very good at, is build a commit and refine it before you publish it.
In Subversion I usually make commits that touch files that just don't "deserve" their own commit, and not mention it in the commit message. It could be that I changed a typo in the docstring for a function or something.
It's not like I wouldn't want to commit it by itself, but when there are a couple of such changes in your working directory, with Subversion, you just go "Meh." and commit it all.
With Git, however, you're encouraged to only commit the changes that belong to one commit. The best, most powerful feature in Git, which Hg sadly lacks, is the ability to add parts of a file to a commit. This is, coincidentally, where Subversion is impossible to work with.
So in short, mr. Bennett, committing is what makes me choose Git over Hg.