Friday, February 22, 2008

How Python Runs Programs

Chapter 2


How Python Runs Programs


The Python interpreter runs all the code written in Python. The compilation process in Python is in two phases; when Python codes are written using any text editor available, it can be compiled through the Windows command line/prompt. The Python Interpreter then compile these source codes to byte codes, a low-level language in which the computer can understand, before execution. The Python Virtual Machine (PVM), which is the python runtime environment, then executes these byte codes for the program output.


Source Codes

Byte Codes

Python Virtual Machine (PVM)


Python runs programs immediately they are executed into byte codes, unlike other compiled languages like C and C++ which make room for a recompilation exercise before the execution. The code compilation/execution cycle in Python is therefore straight forward and the most dynamic. For it give room for easy and fast development.


Other Implementation Alternatives


The explanations above suites the Cpython implementation, that is the standard implementation of the Python language. It is the common and the official Python Implementation, which compiled languages like C and C++ deploy. However, other implementations of code execution in Python abound; there is the Jython (or Java Python), a Java specific version of python for the Java developers, who adopt it as a scripting language in applets and java servelets. There is equally the IronPython, which is Windows specific and is used for .NET and C# language developments. With the exception of Cpython above, all other implementations of the Python language seems to have a more specific compilation and execution procedures different from that of the Cpython.


Other execution models of the Python language are Just-in-time Compiler and Shedding C++ Translator. The chapter closed with a brief about "Frozen Binaries", the packaging scheme for all Python coded programs.

Thursday, February 21, 2008

A Simple Database Project Using Office Access 2007

A local Nursery/Primary school is in dire need of a small database that will take care of their piling flat files folders around, and as a friend of the school, I took the daunting task, though silently. The purpose is to give the school management a “practical” surprise with the database, using Microsoft Office Access 2007. I am aware of the sleek and powerful features of the Office 2007 programs Microsoft has released some few months ago. So I choose Access, and am sure it will deliver. This project is very important to the school with regards to proper records keeping. The school boasts of 200 students that attends lectures/lessons at different hours of the day, throughout the week, with the exclusion of Thursdays and Fridays. There are eight teachers around, with a Headmaster and a Committee that oversees the administration of the school.

After a careful look at the project, I came up with a proposal on how to go about the entire project. But first and foremost, everything, as usual, revolves around the six major Objects of a good database management system. These are:

1. Tables (where all the data are to be stored);

2. Queries (form tools that will assist in fetching data using different formats);

3. Forms (the forms assist in inputting data into the tables, and querying such tables in times of need);

4. Reports (a better way of getting the data out of the database for decision making – by printing, viewing etc);

5. Macros (macros are the simplest ways of giving the application order, in order to carry out some recurring events or functions);

6. Modules

The nature of the database should include the following:

1. All the six major objects of a database;

2. Customisation of all forms (both input and query forms) for a good user interface;

3. User account management;

4. Data Security, including backups;

5. Data Analysis features (with regards to income and expenditure, accounting-wise).

The structure of the school management (with regards to admission, recruiting teachers, payment of registration fees, salaries and other income/expenditure) have been observed and I have the following with regards to this:

1. A student register (from tables to input/query forms);

2. Income register (including forms for fees and other income);

3. Personnel Register (for teachers and other support staff of the school);

4. Expenditure register (for all the expenses the school made);

5. A simple General Ledger, for financial discipline and analysis.

The project looks simple but it has a lot in terms of time and technical resource needs. After all, Access has been a very sophisticated database tool, unlike a simple word processing program like Office Word. Let me see whether in the next 30 days I can deliver. The progress shall always be reported here, as usual. Keep a date with this project.

Cheerio!

Wednesday, February 20, 2008

Starting With Python 2.5

The popular open source programming language, Python, has been making the news with its efficient techniques and reusable codes. For the past 15years after its inception, more than 1million developers have either start or switched to Python. There are many books of Python of course in my custody, but would prefer to start with that of Mark Lutz, a famous developer and teacher of the language for more than fifteen years.

I have downloaded the Python IDE and Command shell already from the Python Website. After reading the installation instruction, I unbundled it on to my system and very soon, the tutorial will start.

One thing with Python is its simplicity and code reusability. With this, I mean, you can easily read Python codes, maintain and deploy them to other compiled languages like C and C++. Python also has the option of Object-Oriented Programming. You can equally use Python to program almost everything you want a computer to do for you; from database, file sharing, web design, server administration, games programming, GUI development and many more.

The book is around 500pps and my timeline is to see through in the next one month, all things being equal. Feel free to post your comments.

Monday, February 11, 2008

UBUNTU: The Linux Touch!

Ever since I have started using the computer system, my experience has always been with the Windows Operating system, owned and developed by the Microsoft Corporation. However, I decided this time around to change environment, to a different clime, so to say. Linux has always been in my mind, but the problem of not having a system of my own and the wherewithal (financially) to own a commercial distribution (like Fedora, Suse, Debian, etc) always discourage my will.


Luckily, I can now boast of a new HP Notebook with Vista pre-installed. And with the recent update of Ubuntu, a free, open source Linux distribution, I thought of switching without any hitches. There are reports (many of them) of incompatibility with Windows partition and booting processes. Nevertheless, I decided to take the risk to dual-boot.

Ubuntu is one of the free Linux distributions making the rounds now. Many are now dual-booting Vista with Ubuntu, at a less or free cost to their pause or hardware. The latest update is 7.10 and can be downloaded here. After downloading the CD/DVD images, you must burn it in order to make it a live bootable CD for your installation. But you must have a very fast Internet connection (broadband). The iso file is somewhere around 700MG. If don’t have a very fast Internet connection, then request for a live bootable CD for free from this site. What I did was to request for a live CD, and I received it after three weeks from the date I applied for it. It all depends on your location across the world.


For long I have been nursing the intention of using this distribution, and have been using the Ubuntu development/community website for my latest information. After receiving the free live CD, I obtained all the necessary information that can enable me to do that, easily, and started as follows:

  1. I backup all my data into a 4GB DVD plate;
  2. Ubuntu live CD does not come with any documentation a part from the little information at the back of the envelope. So I googled for all the necessary information required, and I have gotten much. Catch phrases like: “Dual-booting Ubuntu on Vista”, “Dual-booting Ubuntu on Windows” assisted me a lot;
  3. I read through most of the tutorials, with a special attention on the comments sections, where I found most of the common errors some have gone through;
  4. I boot up my system, and go to Computer Management (Start > Search > type Computer Management). I moved down to Disk Management on the left pane; double-clicked it, to view all my drives on the right pane;
  5. I then shrink my drive C (right-click ‘C’, click shrink volume). A window popped up, showing the available space I can shrink from “C” drive (21G). I selected it, clicked “ok”, and the changes took place. A partition has now been created, where Ubuntu is going to lodge itself;
  6. I then inserted my live CD into the DVD/CD ROM drive, and restart my system.
  7. As expected, the system boot from the live CD, and there, I saw the Ubuntu logo, commanding me to press “enter”, in order to commence the process. I press “enter”;
  8. At the initial stage, Ubuntu will install all the files onto your RAM and restart your system. So it did to me, and after restarting the system, I clicked on the Ubuntu logo on my desktop folder, and the real installation commenced;
  9. I was asked the normal questions; your name, username, region/country, time zone, and the partition I intended to port Ubuntu, I selected the partition I created (it calls it unused volume). After all these, the entire files were installed and was told to eject my live CD, as the system will soon restart immediately. I did as instructed;
  10. After a few tens of seconds, the system restarted, and there was I, in the world of Linux. Waoooooooo!!!;
  11. I then move, according to the instructions on the manual I obtained online, to make a file copy of the GRUB file in case of any eventuality. I went straight to the terminal – Applications > Accessories > Terminal - (like the DOS Shell or Command Prompt in Windows), and type the following command:

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_bak

and hit the "enter" button from my keyboard. This makes a copy of the grub file available in case of any failure. Of course I was asked my password, which I produced and the changes effected.

  1. I then proceed to type another set of command again, calling the grub file, in order to make some certain changes. To open the grub file in a text editor, I typed:

Sudo gedit /boot/grub/menu.lst

I hit enter and the grub file opened. I changed the system booting timeout from 10seconds to 15, and equally changed the booting sequence; instead of allowing Ubuntu, I let Vista be the default operating system, in the absence of any choice after the 15seconds timeout. I clicked "save changes", and exit. (You can find a comprehensive tutorial on how to do everything, with pictorials here)

From the experience I had installing and using Ubuntu, it seems the Ubuntu community has done a lot enhance this latest update. Because most of the problems users had with previous versions are no longer there, at all. One important feature of this free OS is that, you can share it with anybody, anywhere in the world. In fact, that has been the philosophy within the Linux circle. Knowledge, they say, must be free and useable at whatever circumstances. Ubuntu is very efficient, fast and boots within seconds. You can set the prestigious background or desktop effects. They remind me of the Windows Vista aero glass. There are equally office packages pre-installed. You have OpenOffice Word Processor, Spreadsheet, Presentation, Database and Graphics packages as you install Ubuntu. I always appreciate Ubuntu's power management, compare to Vista, which consumes all the power with its overwhelming graphics and absolute disk usage.

For now, I am still experimenting with Ubuntu, and if possible, will like to move to Debian, the main source of Ubuntu's strength. A lot has been said on the power of Linuux systems these days, and there is all indication that in the next decade and a half, Microsoft will find it very difficult to push aside the forceful power of Linux distributions in the home PC front.

Friday, February 8, 2008

My Tutorial Notes

For seven years I have been harboring the intent of becoming a computer programmer, but the saying that programming is the most difficult aspect in the knowledge of technology sends me shivering. I later on reaslise that though it all depends on your interest and what you promise to put in, in order to realize your dream.

Armed with this conception, I decided to go it all, starting with the basics in C#, using the Microsoft Visual Studio 2008 Express Edition. I have alot of interests in C, C++ and Java, but decided to start with C#. You may be reading somethings on PHP, MySQL, CSS, .NET, SQL Server 2005, Ruby, Python, and some updated stuff from Windows Vista security blogs.

In this blog, you shall be reading about my lessons, tutorials I undergo in some C# books (there are many of them of course). Am not a guru yet, just started learning the language or art. So, the content of this blog is authoritative at all. Consider it as my note book which I use in learning a subject or art in the classroom, though.

Feel free to contribute.