Fun with Python’s “import this”

Everyone knows that when you perform import this, in your Python script, you get a printout of The Zen of Python, by Tim Peters.

However, what else is there in the this module?

>>> import this
The Zen of Python, by Tim Peters
>>> help(this)
Help on module this:


    c = 97
    d = {'A': 'N', 'B': 'O', 'C': 'P', 'D': 'Q', 'E': 'R', ...
    i = 25
    s = "Gur Mra bs Clguba, ol Gvz Crgref\n\nOrnhgvshy vf o...

It looks like The Zen of Python text is stored in the module as this.s in ROT-13 encrypted form. The table for decoding this text is stored in this.d.

What is the most Pythonic way to decode the text in this.s?

  1. Loop over the characters in this.s:
    [something(c) for c in this.s]
  2. Decode c if it is encoded (is in the this.d dictionary):
    [(this.d[c] if c in this.d else c) for c in this.s]
  3. The result of the comprehension is a list of characters. Make a string out of it:
    ''.join([(this.d[c] if c in this.d else c) for c in this.s])
  4. Now, print the result:
    print(''.join([(this.d[c] if c in this.d else c) for c in this.s]))

That’s all, folks!

How to manage money before registration of the Hamakor nonprofit

Hamakor – an Israeli nonprofit for Free Software and Open Code was founded at 2003 and one of its goals is to help deal with money when organizing various activities around Free Software.

Before founding Hamakor, people resorted to other solutions. In one exhibition, we wanted to distribute Linux installation CD-ROMs to the crowd. However, we wanted those CD-ROMs to reach only people who have a serious intent to install Linux. A way to ensure it was to require them to donate money in exchange for their CD-ROM. However, if we collect money, we must issue receipts and do bookkeeping.

Truly Yours had the brilliant idea of inviting other nonprofits to send a representative to collect the donations and issue receipts. It was a win-win-win solution. We get someone to issue receipts and sweat over the bookkeeping. The nonprofits get money for their operations. The people, who paid for their CD-ROMs, treat them seriously.

One of the nonprofits was the Association of the Deaf in Israel.

Thank you letter from the Association of the Deaf in Israel
Thank you from the Association of the Deaf in Israel

40th anniversary of the 1971 San Fernando earthquake

Today (February 9, 2011) is the 40th anniversary of the 1971 San
Fernando earthquake

I was in Los Angeles at the time.

When the earthquake hit, I didn’t understand why my parents switched to waking me for school by shaking the bed – until my father told me that it was an earthquake.

I also remember my father the geologist trying to locate the approximate location of the epicenter, before anything was known, by noting the direction of oscillations of the chandeliers at our apartment.

After the main shock, there were sevearl aftershocks during the next few days.

היום (9 בפברואר 2011) הינו היובל ה-40 לרעידת האדמה שקרתה בעמק סן פרננדו (לוס אנג’לס, קליפורניה) בשנת 1971.


באותו הזמן הייתי בלוס אנג’לס.

כשרעידת האדמה הכתה בנו, לא הבנתי למה הורי עברו לשיטת ניעור המיטה כדי להעיר אותי לבית הספר – עד שאבי סיפר לי שזו היתה רעידת אדמה.

אני גם זוכר שאבי הגיאולוג ניסה לאתר את המיקום המשוער של מוקד רעידת האדמה, לפני שפורסם מידע כלשהו, על ידי תשומת לב לכיוון שבו הטלטלו הנברשות בדירתנו.

אחרי הזעזוע הראשי, היו רעידות משנה רבות בימים הבאים.

Davka דווקא is missing from English

Mark L. Levinson writes a blog, which specializes in translating certain difficult words from Hebrew into English.  Today’s word is דווקא (davka).

I was especially amused by the rant that the word entered the Hebrew language, from the Aramaic, too late to be used in the Bible.

For those who don’t have the language parsing and processing ability of serious software developers:

The title of this post means – davka the concept embodied in the word “davka” is missing from English.

Surrealistic events sometimes happen even to a boring life

Three years ago, I was in London.  In subsequent years, I continued to chat and meet Susan, the sharp tongue and teasing sense of humor, and we visited each other, enriching the airlines in the process.

One Friday evening, we walked from Mike’s Place in Tel Aviv to a bus station, in which we were going to pick up “sherut” to transport us back to my home.  The way was long and she got tired.  We sat on a fence and two black and skinny kittens approached her and charmed her.

Few weeks later, she persuaded me to go to help Yaeli catch those kittens.  By almost Douglas Adams style coincidence, at the same time, Billie went down to feed her cats and caught us in the process of stealing two of her kittens!  There were some communication problems, serious misunderstandings, and lots of suspicions, but eventually things were straightened out, as Billie basically needed to find homes for two of her kittens.

Another month passed, and in Susan’s next visit to Israel, all partners and victims in crime met and enjoyed a dinner in a Chinese restaurant near Migdal Shalom in Tel Aviv.  The kittens were caught, neutered and shipped off to England, to serve their 6-month long prison sentence for the crime of charming an English lady (rather than an Israeli).

Now the cats have been released from their quarantine and are starting their new lives in a Southern English home which already has 4 cats.

Updated warning to spammers

Due to shifting values of currencies, I updated the language of the standard spam warning text, which I affix to E-mail messages sent to public mailing lists, and to other information, which I put in the public Internet.

At this opportunity, I also improved a bit the styling and added links to certain stuff which I consider to be Very Important.

It must be a Monty Python skit!

The TDDPirate was red-haired (what the English call “ginger”) at his childhood. He remembers people being positive about his hair color.

He was startled by the news items Red-headed family forced to move after ‘ginger’ hate campaign and Is gingerism as bad as racism?.

Turns out that in England, red-haired people are singled out for teasing and harassment. And this is not an April Fool Day story either.

Thanks to for the links to the above news items.

About having two ears and one mouth

According to Dale Carnegie, God gave humans two ears and only one mouth so that they’ll speak less and listen more.
For deaf people, it is two eyes vs. one mouth.
What about exterrestrials with two mouths and one ear? If they have a Dale Carnegie, he would have said to them that this is what they got because speech is cheap – they got two mouths – but listening is precious – they have only one ear for this.

Funny newspaper gaffes demonstrates just how funny can newspaper gaffes be sometimes. My all-time favorite is the gaffe in an Israeli newspaper from a generation ago. It was about a woman who owes 1000 nights to a tax collector (the Israeli word for night – layla – can easily be a misspelling for the name of the former Israeli monetary unit – lira, if both are written in Hebrew).

Scheduled Electric Power Outage

A week ago the Electric Company announced a power outage scheduled for Wednesday night, to last until 07:00 on Thursday morning, due to maintenance work on the electric power supply grid in my street.
The week elapsed and also the powerless night. At 07:45 the power has not been restored, yet.
I went to the grocery shop to buy my usual morning addictions (newspaper and bread).
The grocery shop was lighted by a candle.
The shopkeeper vented about the absence of electricity. I told him about the scheduled power outage and about the fact that we should have got power back by 07:00.
He phoned the Electric Company. After a brief conversation, he told me that they told him that power will be back ten minutes later.
We laughed, knowing that the promise for electric power was empty.
The time was already 07:50. I returned home with my morning addictions.

At 08:00, power was back.

%d bloggers like this: