Thursday, March 1, 2012

Trading spaces


When learning to use Python for the first time, I turned to Zed Shaw's booklet, Learn Python the Hard Way. The initial exercises were a shade tedious as its intended audience is a complete beginner. In the end, I much enjoyed his style of introducing mechanisms without explanation and giving the answer later. In that space I form an association, whereas the novice can form a hypothesis. Both are useful. I heartily reccommend it to anyone who wants to learn to use Python and isn't an Expert in another language.

One suggestion he makes - I've seen it elsewhere, involves using underscored_variable_names rather than camelCasedVariableNames. I admit, it is more pleasant to look at and discern. But, the underscore is way high up on the keyboard, using my weakest finger. I would have little argument (compactness) if the key were as central as the spacebar it replaces. So, principle ignored.

But, today, I recalled another piece of advice I ignored, this by Steve Yegge. In a primer about using emacs, he suggests that a potential user switch the effects of the alt and caps lock key. Emacs uses a number of keyboard shortcuts that begin with alt. Yegge changed his setup to reduce strain in cupping his hand awkwardly to accomplish the most used sequences. He proceeded to explain how to do so in windows. I prefer emacs to vim, but prefer other editors to emacs, so that was a non-starter. (Not to mention an inconvenience with any computer I don't control, like when I switched to Dvorak.)

The connection came, what if I change the registry to promote a space into an underscore when used in conjunction with a shift key? It would promote this other practice that is useful across software. Admittedly, it may promote an uncomfortable habit when I work on other computers, but the habit would be nicer on the whole. Frankly, I'd have done it rather than writing this but for the death of our modem. It has served at least six years, when its expected lifespan was three. It operated at rates comparable to last year's model, so it is a great shame. Plus, no internet leaves Jack dull, boy. I occasionally wondered if we could improve its lifespan by leaving it off at night but stayed my hand in case it would frustrate my similarly nightowl sister.

I have not touched a project to implement Deitel's Simpletron in Python in twenty days. I felt disappointed by how crudely it failed to act as expected. The problem seemed to arise from a concern I had thought resolved earlier. (Instructions ended up pointing at some list index rather than a memory location.) While I originally hoped to use a dict(ionary/hash), I had more that a pair of values to associate. I decided to use a wrapper with a list and now the implementation largely reflects expecting index values and searching it. Tonight I realized that the symbol should be the key and the wrapper, sans symbol, should be the value. Obvious in retrospect. Further, I could even pare down to a normal dict if I use a string-number for line numbers and integers as const values. Then the value is the memory location.


My only reservation is the degree of change this will require. I'm finally studying how git handles branches, so I can make a verbose version separate. Yet another thing to try.

No comments:

Post a Comment