橫琴.單車.蠔與文藝激盪的半日活動
My problem with the obvious solution to my unexposed types problem
In my last entry about solving my unexposed types problem , I sort of cheated; I left out one obvious solution.My problem was that I wanted to have a function with 'polymorphicarguments', one that could take either strings or compiled regularexpressions and then tell them apart.
Well, you know, one obvious solution is to not have such a crazyinterface in the first place. A clearer, simpler approach would be tohave two separate functions, one that takes compiled regular expressionsand a second one that
修羅場
周日與阿P一起表演
A gotcha with Bash on Ubuntu 8.04
Suppose that you have an Ubuntu 8.04 system where you have opted to make/bin/sh be bash, the way it used to be in 6.06, and you have an accountwith /bin/sh as the login shell (for example, you created it with plain useradd ). So you log in to the account and everything seems normal andbash-y, until you try to do filename completion and get:
$ cd / -sh: <( compgen -d -
Solving unexposed types and the limits of duck typing
When I ran into the issue of the re module not exposing its types , I considered several solutions to my underlyingproblem of distinguishing strings from compiled regular expressions.For various reasons, I wound up picking the solution that was the leastannoying to code; I decided whether something was compiled regularexpression by checking to see if it had a .match attribute.
This is the traditional Python approach to the problem; don't checktypes as such, just check to see if the object has the behavior thatyou'
反平反《下女》
A shell script thing that I have learned the hard way
Here is a note to myself about shell scripting, especially things that Iwrite on the fly on the command line: under no circumstance should I useany ' for ... ' loop index variable apart from $i .
I say this because, based on experimental evidence so far, I amcompletely sure to use $i in the body of the for loop, no matterwhat sensible variable name I picked as the loop index in the for statement. And, of course, the Bourne shell will let me
說服的勝利者
可不是嗎?令得一個人失態地說出這種賭氣的說話,他必然是欠缺了對人的體察,以為憑著充份的道理,就可以說服得別人五體投地?說服,本