Archive for January, 2010

Dive into Python

January 5th, 2010 subogero Comments off


I am very interested in the chronology of Biblical events (anything in the Bible, actually).
Problem: the Bible refers to the time of events always relative to other events. When was the Big Flood relative to Adam’s creation? All we are told is it happened when Noah was 600 years old.

The goal:

  • Create a program that calculates the time of biblical events relative to a single event.
  • The events shall be entered as specified in the Bible, that is, relative to other events.
  • Events should have an optional duration (e.g. the life of Methuselah).
  • Print the result in a nice table-like format
  • Create a timeline diagram

The means: Python

Events are entered into an xml-file, specifying a reference event and a start-time relative to that, and an optional duration. There must be a root event without a reference event, obviously. It looks like this:

  <event name="Adam" duration="930"/>
  <event name="Seth" ref="Adam" start="130" duration="912"/>
  <event name="Enos" ref="Seth" start="105" duration="905"/>
  <event name="Kenan" ref="Enos" start="90" duration="910"/>
  <event name="Mahalalel" ref="Kenan" start="70" duration="895"/>
  <event name="Jared" ref="Mahalalel" start="65" duration="962"/>
  <event name="Enoch" ref="Jared" start="162" duration="365"/>
  <event name="Methuselah" ref="Enoch" start="65" duration="969"/>
  <event name="Lamech" ref="Methuselah" start="187" duration="777"/>
  <event name="Noah" ref="Lamech" start="182" duration="950"/>
  <event name="Shem" ref="Noah" start="502" duration="600"/>
  <event name="Ham" ref="Noah" start="502"/>
  <event name="Japhet" ref="Noah" start="502"/>
  <event name="Flood" ref="Noah" start="600" duration="1"/>

The xml file is passed to the Python program as an argument, which parses it using the xml.dom.minidom package. An optional argument specifies the name of the event at zero years, otherwise everything is calculated from the root event (Adam).

$ ./ BibleTime.xml Adam

We get this on the console:

       Adam     0   930
       Seth   130  1042
       Enos   235  1140
      Kenan   325  1235
  Mahalalel   395  1290
      Jared   460  1422
      Enoch   622   987
 Methuselah   687  1656
     Lamech   874  1651
       Noah  1056  2006
       Shem  1558  2158
        Ham  1558
     Japhet  1558
      Flood  1656  1657

If you call, you also get a timeline window using the Tk-binding of Python, the Tkinter package:



Before, I did not know Python, never made GUI programs and never used XML. This program took me less than one day to develop. Any questions?

The source code: bible.7z