Many thanks for an excellent solution to the problem and clearing up my mind about globals. In some sense, Python globals seem to be a little like the COMMON statement in the old Fortran 77 standard.