What is a pipe
Conceptually a pipe can be thought of much like a hose-pipe, in that it is a conduit where we pour data in at one end and it flows out at the other. A pipe looks a lot like a file in that it is treated as a sequential data stream. Unlike a file, a pipe has two ends, so when we create a pipe we get two end points back in return. We can write to one end point and read from the other. Also unlike a file, there is no physical storage of data when we close a pipe, anything that was written in one...
The Address Book as ClientServer
Back in the files topic we built a version of our address book using a dictionary. Let's reuse that example but this time we will build a client server version. Notice that the original code broke one of the good practice rules we discussed earlier I included User Interface code in my helper functions. If we were to try to use this code we would get messages from the child process mixed up with messages from the parent. We need to tweak the code slightly so that we can turn it into a reusable...
SalaryID Grade Amount
Now we can look up the grade of an Employee, such as John, and find that they are a Foreman, then by looking at the Salary table we can see that a Foreman is paid 60000. It is this ability to link table rows together in relationships that gives relational databases their name. Other database types include network databases, hierarchical databases and flat-file databases. Relational databases are by far the most common. We can do much more sophisticated queries too and we will look at how this...
Things to remember Xmx
Event loops do not care about the events they detect Event handlers handle one single event at a time Frameworks such as Tkinter provide an event loop and often some default event handlers too. Web browsers provide for both batch and event driven coding styles, or even a mixture of both. If you have any questions or feedback on this page send me mail at alan.gauld btinternet.com
Event Driven Programming in VBScript and JavaScript
Both VBScript and JavaScript can be used in an event driven manner when programming a web browser. Normally when a web page containing script code is loaded the script is executed in a batch fashion as the page loads. However if the script contains nothing but function definitions the execution will do nothing but define the functions ready for use, but the functions will not be called initially. Instead, in the HTML part of the page the functions will be bound to HTML elements - usually within...
Changing permissions of Files
Having discovered what the permissions on a file are currently set to we can also use the os module to change those permissions to something more suitable. Python uses the Unix conventions for changing permissions whereby each file has a set of three flags read, write, execute for each of three user categories owner, group and world . Thus there are a total of 9 flags per file. These are represented by nine bits. These bits make up the rightmost bits of the permissions flag returned by os.stat...
An alternative wxPython
There are many other GUI toolkits available but one of the most popular is the wxPython toolkit which is, in turn, a wrapper for the C toolkit wxWidgets. wxPython is much more typical than Tkinter of GUI toolkits in general. It also provides more standard functionality than Tk out of the box - things like tooltips, status bars etc which have to be hand crafted in Tkinter. We'll use wxPython to recreate the simple Hello World Label and Button example above. I won't go through this in detail, if...
Running an external program ospopen
In fact there are several variations of the popen command called popen, popen2, popen3 and popen4. The numbers refer to the various data stream combinations that are made available. The standard data streams were described in a sidebar in the Talking to the User topic. The basic version of popen simply creates a single data stream where all input output is sent received depending on a mode parameter passed to the function. In essence it tries to make executing a command look like using a file...
EmpID Name HireDate Grade ManagerlD
1020304 John Brown 20030623 Foreman 1020311 1020305 Fred Smith 20040302 Labourer 1020304 1020307 Anne Jones 19991125 Labourer 1020304 Notice a couple of conventions here 1. We have an id field to uniquely identify each row, this is known as the Primary Key. It is possible to have other keys too, but conventionally there will always be an ID field to uniquely identify a record. This helps should an employee decide to change their name for example 2. We can link one row to another by having a...
Integers
Integers are whole numbers from a large negative value through to a large positive value. That's an important point to remember. Normally we don't think of numbers being restricted in size but on a computer there are upper and lower limits. The size of this upper limit is known as MAXINT and depends on the number of bits used on your computer to represent a number. On most current computers and programming languages it's 32 bits so MAXINT is around 2 billion however VBScript is limited to about...
Non English Editions now available
Martin Pozzi was the first to translate the tutor into Spanish and he has now been followed by several others. The following versions are available The tutors above are all usable but at different stages of completeness compared to the web site. That's because they reflect the state of the web site at the time of translation. The Czech one in particular is very professionally presented including a very attractive appearance. I was so impressed with the style that I have used Petr's stylesheets...
A Brief History of Error Handling
Error handling is the process of catching the errors generated by our program and hiding them from our users. It doesn't matter too much if we, as programmers get exposed to a Python error message - we are supposed to understand all that techno speak. But our users are probably not programmers and they want nice, easy to understand messages when things go wrong, and ideally, they want us to catch the error and fix it without them ever knowing about it And that's where error handling comes in....

