1. Python Create Modify Reuse Knowlton James O
download
https://ebookbell.com/product/python-create-modify-reuse-
knowlton-james-o-22122856
Explore and download more ebooks at ebookbell.com
2. Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Python Create Modify Reuse James O Knowlton
https://ebookbell.com/product/python-create-modify-reuse-james-o-
knowlton-34684816
Make Games With Python Create Your Own Entertainment With Raspberry Pi
1st Edition Sean M Tracey
https://ebookbell.com/product/make-games-with-python-create-your-own-
entertainment-with-raspberry-pi-1st-edition-sean-m-tracey-50478096
Building Etl Pipelines With Python Create And Deploy Enterpriseready
Etl Pipelines By Employing Modern Methods Anonymous
https://ebookbell.com/product/building-etl-pipelines-with-python-
create-and-deploy-enterpriseready-etl-pipelines-by-employing-modern-
methods-anonymous-55335112
Building Etl Pipelines With Python Create And Deploy Enterpriseready
Etl Pipelines By Employing Modern Methods 1st Edition Brij Kishore
Pandey
https://ebookbell.com/product/building-etl-pipelines-with-python-
create-and-deploy-enterpriseready-etl-pipelines-by-employing-modern-
methods-1st-edition-brij-kishore-pandey-52871262
3. Machine Learning Cookbook With Python Create Ml And Data Analytics
Projects Using Some Amazing Open Datasets Rehan Guha
https://ebookbell.com/product/machine-learning-cookbook-with-python-
create-ml-and-data-analytics-projects-using-some-amazing-open-
datasets-rehan-guha-44887920
Coding With Python Create Amazing Graphics Max Wainewright
https://ebookbell.com/product/coding-with-python-create-amazing-
graphics-max-wainewright-51266596
Data Visualization With Python Create An Impact With Meaningful Data
Insights Using Interactive And Engaging Visuals Dbler
https://ebookbell.com/product/data-visualization-with-python-create-
an-impact-with-meaningful-data-insights-using-interactive-and-
engaging-visuals-dbler-20632932
Data Visualization With Python Create An Impact With Meaningful Data
Insights Using Interactive And Engaging Visuals Mario Dbler Tim
Gromann
https://ebookbell.com/product/data-visualization-with-python-create-
an-impact-with-meaningful-data-insights-using-interactive-and-
engaging-visuals-mario-dbler-tim-gromann-11267558
Ultimate Neural Network Programming With Python Create Powerful Modern
Ai Systems By Harnessing Neural Networks With Python Keras And
Tensorflow 1st Edition Vishal Rajput
https://ebookbell.com/product/ultimate-neural-network-programming-
with-python-create-powerful-modern-ai-systems-by-harnessing-neural-
networks-with-python-keras-and-tensorflow-1st-edition-vishal-
rajput-53620894
8. Python®
Create-Modify-Reuse
Introduction .............................................................................................. xix
Chapter 1: A Python Primer........................................................................ 1
Part I: The Projects ................................................................................... 17
Chapter 2: Directory/File Snapshot Program .............................................. 19
Chapter 3: DVD Inventory System .............................................................. 43
Chapter 4: Web Performance Tester ........................................................... 81
Chapter 5: Customer Follow-Up System...................................................... 103
Chapter 6: Test Management/Reporting System........................................ 125
Chapter 7: Version Management System .................................................... 157
Chapter 8: Content Management System ................................................... 177
Part II: Advanced Topics ............................................................................ 197
Chapter 9: Interacting with the Operating System ...................................... 199
Chapter 10: Debugging and Testing............................................................ 221
Appendix A: Where to Go From Here — Resources That Can Help................ 239
Appendix B: Installing Supplemental Programs ........................................... 241
Index ........................................................................................................ 253
ffirs.indd i
ffirs.indd i 6/2/08 12:20:01 PM
6/2/08 12:20:01 PM
12. To Karin, the love of my life. Words simply can’t express all that I’m grateful for. I know that sometimes I live in
another world — but always know that it would be a cold world without you.
To my children, Karren, Shannon, Kasey, Brian, Courtney, Jaren, Carlen, Kristin, Logan, and Ben — and to little
Olivia yet to come (as I write this). For some of you I was there at your birth, some of you I have known
for only a few years, but know that each one of you is a treasure to me.
To Mom and Dad, you are still with me every day. I live to make you proud.
ffirs.indd v
ffirs.indd v 6/2/08 12:20:03 PM
6/2/08 12:20:03 PM
14. vii
About the Author
Jim Knowlton is a software quality engineer with Automatic Data Processing (ADP), Inc., where he
leads quality assurance efforts on ADP’s computer telephony integration and network video projects.
He has been instrumental in introducing automated testing methodologies to their QA effort. He has
more than fifteen years of experience in the software industry, including clients such as Symantec,
Novell, Nike, and Zions Bank. He has extensive experience in open-source technologies, including
Python, Ruby, PHP, Apache, and MySQL, and has also worked extensively in the areas of systems
management and enterprise security. Jim holds a bachelor of arts degree in management and is currently
working on a master of software engineering degree at Portland State University.
ffirs.indd vii
ffirs.indd vii 6/2/08 12:20:03 PM
6/2/08 12:20:03 PM
16. Acquisitions Editor
Jenny Watson
Development Editor
Ed Connor
Technical Editor
Jesse Keating
Production Editor
Daniel Scribner
Copy Editor
Expat Editing
Editorial Manager
Mary Beth Wakefield
Credits
Production Manager
Tim Tate
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Joseph B. Wikert
Project Coordinator, Cover
Lynsey Stanford
Proofreader
Nancy Carrasco
Indexer
Robert Swanson
ffirs.indd ix
ffirs.indd ix 6/2/08 12:20:03 PM
6/2/08 12:20:03 PM
18. Acknowledgments
First, I’d like to acknowledge Guido Van Rossum for creating such a way cool language as Python.
I’d like to thank my agent, Neil Salkind, for nursing my insecurities and answering my novice writer
questions.
I’d like to thank Jenny Watson, my acquisitions editor at Wiley, for being willing to go to bat for an
unpublished writer’s crazy ideas. Thanks to Ed Connor, my development editor, for his gentle prodding,
high standards, and encouragement. Thanks also to Jesse Keating for his help with technical editing, and
to Brent Rufener for providing a cover photo.
Finally, but most important, thanks to my family for putting up with my frequent unavailability during the
last few months — writing is a solitary art, and it will be nice to reacquaint myself with my loved ones.
ffirs.indd xi
ffirs.indd xi 6/2/08 12:20:04 PM
6/2/08 12:20:04 PM
20. Contents
Introduction xix
Chapter 1: A Python Primer 1
Getting Started 1
Obtaining Python and Installing It 1
The Python Interpreter 2
Your Editing/Execution Environment 2
Lexical Structure 3
Keywords 3
Lines and Indentation 4
Data Types and Identifiers 4
Operators 6
Expressions and Statements 7
Expressions 7
Statements 7
Iteration and Decision-Making 8
Iteration 9
Decision-Making 10
Functions 11
Modules 12
Importing Modules 12
How Python Finds Modules to Load 13
Classes 14
Summary 15
Part I: The Projects 17
Chapter 2: Directory/File Snapshot Program 19
Using the Program 20
Creating a Snapshot 20
Listing Snapshot Files 21
Comparing Snapshots 22
ftoc.indd xiii
ftoc.indd xiii 6/2/08 12:19:07 PM
6/2/08 12:19:07 PM
21. xiv
Contents
Viewing Help 23
Exiting the Program 23
Putting It All Together 24
Design 25
How It All Fits Together 25
Main Program 26
Modules 26
Code and Code Explanation 27
Snapshot.py 27
snapshothelper.py 34
Testing 42
Modifying the Program 42
Summary 42
Chapter 3: DVD Inventory System 43
Using the Program 44
Installing MySQL 44
Adding a DVD to the Database 44
Searching the DVD Inventory 46
Modifying a DVD Record 50
Deleting a DVD Record 53
Exporting the List of DVDs to a CSV File 54
Design 55
How It All Fits Together 56
Modules 56
Code and Code Explanation 58
dvd.py 59
add_dvd.py 61
lookup_dvds.py 63
modify_dvd.py 68
delete_dvd.py 74
csvreport_dvd.py 77
Testing 79
Modifying the Program 79
Summary 80
Chapter 4: Web Performance Tester 81
Using the Program 82
Running the Python Web Server 82
Running the Performance Profiler Client 83
ftoc.indd xiv
ftoc.indd xiv 6/2/08 12:19:07 PM
6/2/08 12:19:07 PM
22. xv
Contents
Design 88
How It All Fits Together 89
Modules 89
Code and Code Explanation 90
webserver.py 90
webperf.py 92
webclient.py 95
Testing 102
Modifying the Program 102
Summary 102
Chapter 5: Customer Follow-Up System 103
Using the Program 103
Preliminaries 104
Running the Program 112
Design 115
How It All Fits Together 115
Modules 116
Code and Code Explanation 117
form.html 117
form.py 118
Testing 123
Modifying the Program 123
Summary 124
Chapter 6: Test Management/Reporting System 125
Using the Program 126
Running Tests 126
Listing Test Runs 129
Showing Test Results 129
Generating an HTML Test Report 130
Examining the HTML File 131
Displaying Product Help 132
Design 133
Modules 133
Code and Code Explanation 135
test_manager.py 135
test_run.py 140
test_list.py 147
test_results.py 148
test_html.py 151
ftoc.indd xv
ftoc.indd xv 6/2/08 12:19:08 PM
6/2/08 12:19:08 PM
23. xvi
Contents
Testing 155
Modifying the Program 155
Summary 155
More About the Minidom Module 156
Chapter 7: Version Management System 157
Using the Program 158
Setting Up Remote Computers 158
Running the Program — Command-Line Syntax 158
Design 162
Modules 162
Code and Code Explanation 163
version_checker.py 164
check_versions.py 168
csv_report.py 173
Testing 174
Modifying the Program 175
Security Considerations 175
Summary 175
Chapter 8: Content Management System 177
Plone Overview 177
What Is Plone? 177
Installing and Configuring Plone 178
Downloading Plone 179
Extracting the Plone Install 180
Running the Plone Install 181
Starting Plone 182
Discovering the Admin User Password 182
Logging In as the Admin User 182
Setting Up the E-mail Server 184
Setting Up a User 185
Logging In as the Set-Up User 186
Design 187
Navigation 189
Content Management 189
Creating a Page 189
Creating a Collection 191
User Permissions 195
Summary 196
ftoc.indd xvi
ftoc.indd xvi 6/2/08 12:19:08 PM
6/2/08 12:19:08 PM
24. xvii
Contents
Part II: Advanced Topics 197
Chapter 9: Interacting with the Operating System 199
Generic Operating System Services 200
The os Module — Generic OS Services 200
The time Module — Format and Manipulate System Time 201
The optparse Module — Parse Command-Line Options 203
The platform Module — Get Platform Information 204
The getpass Module — Generate and Check Passwords 204
Some Other Things You Can Do 205
Accessing Windows Services 205
The winreg Module — Manipulate the Windows Registry 205
The winsound Module 206
The win32serviceutil Module — Manage Windows Services 207
The win32net Module — Access Windows Networking Features 209
Some Other Things You Can Do 211
Accessing Unix/Linux Services 212
The termios Module — Access Unix-Style TTY Interface 212
The resource Module — Manage Unix System Resources 212
The syslog Module — Access the Unix syslog 215
The commands Module — Run Commands and Get Output 217
Some Other Things You Can Do 219
Summary 219
Chapter 10: Debugging and Testing 221
The Python Debugger 221
Running the Debugger 222
Python Test Frameworks 226
Why We Test 226
Unit Testing 227
Summary 237
Final Remarks 237
Appendix A: Where to Go From Here — Resources That Can Help 239
Appendix B: Installing Supplemental Programs 241
Index 253
ftoc.indd xvii
ftoc.indd xvii 6/2/08 12:19:08 PM
6/2/08 12:19:08 PM
26. Introduction
Python: Create-Modify-Reuse is designed for all levels of Python developers interested in a practical,
hands-on way of learning Python development. This book is designed to show you how to use Python
(in combination with the raw processing power of your computer) to accomplish real-world tasks in a
more efficient way. Don’t look for an exhaustive description of the Python language — you won’t find it.
The book’s main purpose is not to thoroughly cover the Python language, but rather to show how you
can use Python to create robust, real-world applications.
In this respect, the goal is similar to foreign-language books that identify themselves as “conversational,”
focusing on the vocabulary and concepts that people will need the most. Likewise, I focus specifically on
the Python knowledge needed to accomplish practical, specific tasks. Along the way, you will learn to
create useful, efficient scripts that are easy to maintain and enhance.
The applications, along with source code, are available for download at www.wrox.com.
Who This Book Is For
This book is for developers with some experience with Python who want to explore how to develop
full-blown applications. It is also for developers with experience in other languages who want to learn
Python by building robust applications. It is well-suited for developers who like to “learn by doing,”
rather than exploring a language feature by feature. To get the most out of the book, you should
understand basic programming principles.
Because this book is project-based, you can approach it in numerous ways. You can, of course, read it from
cover to cover. Chapters 2 through 8 each cover a different project, so the chapters are independent of
each other. However, because each chapter project is covered individually, there may be some overlap
of information. I also sometimes refer to explanations of particular topics covered in previous chapters.
This will help to reinforce important concepts.
The end of the book contains two appendixes. The first one is a listing of Python resources you can check
out for more information. The second one will help you with installing additional components used in
some of the examples.
flast.indd xix
flast.indd xix 6/2/08 12:19:39 PM
6/2/08 12:19:39 PM
27. Introduction
xx
What This Book Covers
I’ve always liked the Saturday morning fix-it shows that demonstrate how to build something, such as a
cabinet or a deck. The experts on these shows take seemingly large, complex tasks that appear to be
beyond the skill level of the average do-it-yourselfer and break them down into smaller, simple tasks,
teaching you valuable skills along the way. That’s basically the intention and approach taken in this
book, applied to the construction of software instead of home improvements.
This book starts with a basic overview of the Python language, designed for those familiar with other
languages but new to Python. It is followed by several chapters, each of which describes a complete
project that can be used as-is or modified and extended to suit your particular purposes. You’ll find
applications that access databases, take advantage of web technologies, and facilitate network
communications, to name a few. In addition, and more important than the technologies you will be
introduced to, you will learn how to use Python to solve real challenges. Following these chapters are
two chapters that cover accessing operating system resources and debugging and testing, respectively.
Each project chapter contains complete instructions describing how to install and use the application, so
you can actually see the program run as you learn how to construct and use it, including how the project
was designed and prototyped. This book is intended to be both a reference guide and a learning aid,
teaching you how to build solutions with Python and providing reference information on a wide variety
of Python programming concepts.
It is hoped that this book will help you have fun with Python and build useful applications, and — unlike
my experience with building a deck — without sore thumbs.
How This Book Is Structured
This book is framed around the code itself. This is because developers are typically looking for how to
do something; and, as with many activities, you learn how to do something by watching how others do
it and trying it yourself. If you want to know how a for loop works, you’ll find for loops in my code,
but that’s not the thrust of the book. Instead, this book shows you how to do things: how to build a
content management system, how to build a test management system, how to set up a system for
tracking customer follow-up, and so on. Along the way, you’ll learn how to communicate with a SQL
database, how to act as a web server or communicate with one, how to access operating system services,
and more.
There are three basic components to the book:
Chapter 1 is a brief overview of the Python language.
Chapters 2–8 cover seven different programming projects, which illustrate various technologies
and techniques available to Python developers.
Chapters 9–10 cover additional, advanced topics, which will help you as you build Python
projects.
❑
❑
❑
flast.indd xx
flast.indd xx 6/2/08 12:19:40 PM
6/2/08 12:19:40 PM
28. Introduction
xxi
The project chapters have a consistent structure:
Overview: What does the application do?
Using the program
Design
❑ How it all fits together
❑ Modules involved
Code and code explanation
❑ Module/class 1 explanation
❑ Module/class 2 explanation
❑ Minor code file explanation
Testing, including suggested tests
Modifying the project, including some suggested adaptations
Summary
Each project is designed with classes that can be reused and accessed for multiple purposes. This is one
of the main benefits of object-oriented programming, so designing for reusability is a main focus of the
book. The book contains the following chapters:
1. A Python Primer
This chapter is a basic primer on the Python language, and it functions as either a quick tutorial
for experienced programmers new to Python or a refresher for programmers with Python
experience.
Part I: The Projects
2. Directory/File Snapshot Program
This project demonstrates how to interact with files, create and manipulate data structures, and
provide user output. It also touches on code design issues to improve code maintainability.
Often when installing or uninstalling software, or verifying changes to a file system, it can be
valuable to take a “snapshot” of the files and directories, along with their size and last-modified
time. The script introduced in this chapter does just that. This chapter also explores how to
capture a directory listing into a Python list, and explains how to query this list for particular
values.
❑
❑
❑
❑
❑
❑
❑
flast.indd xxi
flast.indd xxi 6/2/08 12:19:40 PM
6/2/08 12:19:40 PM
29. Introduction
xxii
3. DVD Inventory System
This project takes advantage of Python’s capability to access and manipulate data in a SQL
database. The application enables multiple users to log in to a website that provides access to a
DVD inventory database. Permissions are set such that some users can add, modify, or delete
entries, whereas other users have read-only access to the data.
4. Web Performance Tester
This project shows how to communicate with a Python web server and retrieve information
regarding how long it takes to receive requested items from the web server. Although writing
Python programs to work on a single computer can be useful, the real power of Python can be
seen when it is used to script communication between computers on a network. Most networks
contain several web servers. A nice feature of Python is that it can act as a lightweight server for
various Internet protocols, such as HTTP (web) and ftp. This application enables you to monitor
performance of HTTP traffic on your network.
5. Customer Follow-Up System
This project shows how to present a web form to the user and retrieve data from it, how to
automatically format and send e-mail through an SMTP server, and how to generate an HTML-
formatted report. The task for the second example is to automatically generate a customer
comments e-mail message based on information the customer enters in a form. It uses the
mod_python Apache module to take the information entered in the HTTP form and then utilizes
a Python script on the web server to send that information to an SMTP server for mail delivery.
6. Test Management/Reporting System
This project makes use of the unittest module to run tests against an existing application, and
creates a framework for reporting test results. Testing is a vital process for developing software.
This application enables users to run tests for a given piece of software, to list the previous test
runs by date, to show test run results for any previously run tests, and to output the results of
any test run as HTML for viewing in a web browser.
7. Version Management System
This project connects to a list of servers via telnet, checks the application version of a pre-set
application list, and displays its results both as output and to a log file. Often, a system
administrator needs to patch systems or ensure that systems have the latest application versions
installed. This script is an easy way to accomplish that task. It makes use of Python’s capability
to emulate a telnet client and log in to remote systems and perform functions on that remote
system.
8. Content Management System
This project explores Plone, a popular content management system based on Python and Zope
(a Python-based application server). Because Python is a very mature language, numerous
applications have been built on top of it. A great thing about working with Python-based
applications is that you get the benefit of a full-blown application, but you can still use Python
to configure and customize it.
flast.indd xxii
flast.indd xxii 6/2/08 12:19:40 PM
6/2/08 12:19:40 PM
30. Introduction
xxiii
Part II: Advanced Topics
9. Interacting with the Operating System
When writing scripts “in the real world,” often it is critical to be able to access services available
through (and particular to) the operating system you happen to be on. For example, suppose
you wanted to read or modify the Window Registry? Or you wanted to get the Linux process ID
of a particular process that is running? Is such a thing even possible? Definitely — and this
chapter shows you how.
10. Debugging and Testing
Because I am a software tester myself, testing is a subject that is certainly close to my heart. In
this chapter, I discuss why testing is important, how to put the right amount of testing into your
code, and how writing automated tests can help you to actually write code more quickly. You’ll
look at PyUnit, the automated testing framework for Python, and learn how to use it to test the
riskiest parts of a script. You’ll also explore the Python debugger and some of the nifty features
it offers.
Appendix A Where to Go from Here: Resources That Can Help
This appendix provides an annotated list of books, websites, and blogs that can provide useful
information, insight, and inspiration for the budding Python script developer.
Appendix B Installing Supplemental Programs
This appendix provides detailed information on how to set up MySQL (used in the project in
Chapter 3) and PyWin32 (used in Chapter 10 and various other projects in the book).
What You Need to Use This Book
For this book, I used Python 2.51 (the “CPython” distribution), run on Windows, as my Python
distribution of choice. Most of the examples will work with the latest versions of Python for Windows,
Mac, or Unix/Linux, or IronPython. However, to successfully run everything in this book, you’ll want
the latest version of CPython on Windows, which is currently version 2.51.
Other applications, such as Plone, are available free and can be downloaded as needed. When you get to
a chapter for which you need an additional component, I’ll indicate that to you, and you can look in
Appendix B for information on installing additional components.
Source Code
As you work through the examples in this book, you may choose either to type in all the code manually
or to use the source code files that accompany the book. All of the source code used in this book is
available for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using
the Search box or by using one of the title lists) and click the Download Code link on the book’s detail
page to obtain all the source code for the book.
flast.indd xxiii
flast.indd xxiii 6/2/08 12:19:40 PM
6/2/08 12:19:40 PM
31. Introduction
xxiv
Because many books have similar titles, you may find it easiest to search by ISBN;
this book’s ISBN is 978-0-470-25932-0.
Once you download the code, just decompress it with your favorite compression tool. Alternately, you
can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to
see the code available for this book and all other Wrox books.
Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is
perfect and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or
faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save
another reader hours of frustration and at the same time you will be helping us provide even higher
quality information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or
one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view
all errata that has been submitted for this book and posted by Wrox editors. A complete book list
including links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport
.shtml and complete the form there to send us the error you have found. I’ll check the information and,
if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of
the book.
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based
system for you to post messages relating to Wrox books and related technologies and interact with other
readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of
your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,
and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as you
read this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
flast.indd xxiv
flast.indd xxiv 6/2/08 12:19:41 PM
6/2/08 12:19:41 PM
32. Introduction
xxv
3. Complete the required information to join, as well as any optional information you wish to
provide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and complete
the joining process.
You can read messages in the forums without joining P2P but in order to post your
own messages, you must join.
Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the Web. If you would like to have new messages from a particular forum
e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to
questions about how the forum software works, as well as many common questions specific to P2P and
Wrox books. To read the FAQs, click the FAQ link on any P2P page.
flast.indd xxv
flast.indd xxv 6/2/08 12:19:41 PM
6/2/08 12:19:41 PM
34. A Python Primer
This chapter provides a quick overview of the Python language. The goal in this chapter is not to
teach you the Python language — excellent books have been written on that subject, such as
Beginning Python (Wrox, 2005). This chapter describes Python’s lexical structure and programming
conventions, so if you are familiar with other scripting languages such as Perl or Ruby, or with
compiled programming languages such as Java or C#, you should easily be up to speed in no time.
Getting Started
Of course, the first thing you need to do is install Python, if you don’t already have it. Installers are
available for Windows, Macintosh, Linux, Unix, and everything from OpenVMS to the Playstation
(no, I’m not kidding).
Obtaining Python and Installing It
If you go to www.python.org/download you can find links to download the correct version of
Python for your operating system. Follow the install instructions for your particular Python
distribution — instructions can vary significantly depending on what operating system you’re
installing to.
What Version Number to Install
Although the examples in this book should work for any Python version above 2.0, it is
best to install the latest stable build for your operating system. For Windows (which is
the environment I primarily work in), the latest stable version is 2.51. There is an alpha
build of Python 3.0 available as of this writing, but other than just looking at it for fun,
I’d steer clear of it for the examples in this book — in some cases the syntax is very
different, and the examples in this book won’t work with Python 3.0.
c01.indd 1
c01.indd 1 6/2/08 12:03:06 PM
6/2/08 12:03:06 PM
35. Chapter 1: A Python Primer
2
The Python Interpreter
One of the most useful tools for writing Python code is the Python interpreter, an interactive editing and
execution environment in which commands are run as soon as you enter them and press Enter. On Unix
and Macintosh machines, the Python interpreter can usually be found in the /usr/local/bin/python
directory, which can be accessed by simply typing the command python.
On Windows machines, the Python interpreter is installed to the c:python25 directory (for a Python
2.5x installation). To add this directory to your path, type the following at a Windows command prompt:
set path=%path%;C:python25.
On a Windows system, such as with Unix/Linux, you simply type python to bring up the interpreter
(either from the c:python25 directory or from any directory if the Python directory has been added to
the path).
When you enter the interpreter, you’ll see a screen with information like the following:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
Your Editing/Execution Environment
Because the minimum requirements for writing and running Python programs are simply an editor that
can save text files and a command prompt where you can run the Python interpreter, you could simply
use Notepad on Windows, Vim on Linux/Unix, or TextEdit on Mac, and a command line for running
programs.
One nice step up from that is IDLE, Python’s integrated development environment (IDE), which is
named after Monty Python’s Eric Idle and is included with Python. It includes the following useful
features:
A full-featured text editor
Syntax highlighting
Code intelligence
A class browser
A Python path browser
A debugger
A Python interpreter environment
❑
❑
❑
❑
❑
❑
❑
c01.indd 2
c01.indd 2 6/2/08 12:03:08 PM
6/2/08 12:03:08 PM
36. Chapter 1: A Python Primer
3
In addition to IDLE, you do have other options. On Windows, there is a nice IDE called PythonWin,
developed by Mark Hammond. It can be installed as a full Python distribution from ActiveState’s
website (www.activestate.com), or you can simply install the win32all package to add PythonWin to a
standard Python for Windows install. PythonWin is a great product, very slick and with all the features
you’d expect from an IDE.
Other options include an Eclipse distribution for Python called EasyEclipse for Python. For my money,
I’d start out with IDLE, and then as your experience with Python grows, explore other options.
Lexical Structure
Following is a simple Python program. It shows the basic structure of many Python scripts, which is as
follows:
1. Initialize variables (lines 1–3).
2. Do some processing (lines 4–5).
3. Make decisions and perform actions based on those decisions (lines 6–10).
name = “Jim”
age = 42
highschoolGPA = 3.89
enteredName = raw_input(“Enter your name: “)
print “nn”
if name == “Jim”:
print “Your age is “, age
print “You had a”, highschoolGPA, “GPA in high school”
if (highschoolGPA > 3):
print “You had better than a 3.0 GPA...good job!”
Keywords
Keywords are words that are “reserved” — they cannot be used as variable names. In the preceding code,
the keyword if is used multiple times.
c01.indd 3
c01.indd 3 6/2/08 12:03:08 PM
6/2/08 12:03:08 PM
37. Chapter 1: A Python Primer
4
The keywords are as follows:
and del for is raise
assert elif from lambda return
break else global not try
class except if or while
continue exec import pass
def finally in print yield
Lines and Indentation
In Python, unlike a compiled language such as C, line breaks are significant, and the end of a program
statement is defined by a hard return. Program blocks are defined by a combination of statements (each
on a separate line, but with no end-of-statement character visible) and program blocks, delimited
visually by the use of indentation.
As shown in the code from the preceding section, lines are indented in Python. This is not simply a
stylistic choice — indentation is not just recommended in Python, but enforced by the interpreter. This is
probably the most controversial aspect of Python, and it has been the subject of many a flame war online.
Basically, it means that the following code would generate an interpreter error, because the action
associated with an if statement must be indented:
if variable1 == “Jim”:
print “variable1 eqiuals Jim”
You’ll learn more about the actual if statement itself later.
Data Types and Identifiers
Python provides a rich collection of data types to enable programmers to perform virtually any
programming task they desire in another language. One nice thing about Python is that it provides many
useful and unique data types (such as tuples and dictionaries), and stays away from data types such as
the pointers used in C, which have their use but can also make programming much more confusing and
difficult for the nonprofessional programmer.
c01.indd 4
c01.indd 4 6/2/08 12:03:08 PM
6/2/08 12:03:08 PM
38. Chapter 1: A Python Primer
5
Data Types
Python is known as a dynamically typed language, which means that you don’t have to explicitly identify
the data type when you initialize a variable. In the code example above, the variable name is assigned to
the string value “Jim”. However, you don’t specifically identify the variable as a string variable. Python
knows, based on the value it has been given, that it should allocate memory for a string. Likewise for the
age integer variable and the highschoolGPA float variable.
The following table shows the most commonly used available data types and their attributes:
Data Type Attributes Example
Numeric Types
Float Implemented with C doubles. 5.43
9483.123
Integer Implemented with C longs. 1027
211234
Long Integer Size is limited only by system resources. 567893L
Sequence Types
String A list of characters. Is immutable (not changeable
in-place). Can be represented by single quotes or
double quotes. Can span multiple lines.
“This is a string”
”””
This is an example
of a DocString
”””
List A mutable (changeable) sequence of data types.
List elements do not have to be “like.” In other
words, you could have a float element and an
integer element in a single list.
[1, 2.3, “Jim”]
[1, 2, 3]
[1.5, 2.7, 3.0]
[“Jim”, “Joe”, “Bob”]
Tuple An immutable sequence of data types. Other
than the fact that it can’t be changed, it works
just like a list.
(1, 2.3, “Jim”)
(1, 2, 3)
(1.5, 2.7, 3.0)
“Jim”, “Joe”, “Bob”
Dictionary A list of items indexed by keys. d = {“first“:”Jim”,
“last“:“Knowlton“}
Identifiers
An identifier is a unique name that enables you to identify something. Identifiers are used to label
variables, functions, classes, objects, and modules. They begin with either a letter or an underscore, and
they can contain letters, underscores, or digits. They cannot contain punctuation marks.
c01.indd 5
c01.indd 5 6/2/08 12:03:09 PM
6/2/08 12:03:09 PM
39. Chapter 1: A Python Primer
6
Operators
If you have programmed in other languages, the operators in Python will be familiar to you. The Python
operators are fundamentally similar to those used in other languages. In the code shown earlier, the
conditions evaluated in both if statements involve comparison operators. The following table describes
the operators most commonly used in Python, and the ones used in this book:
Operator Symbol Example
Numeric Operators
Addition + x + y
Subtraction − x – y
Multiplication * x * y
Division / x / y
Exponent (Power) ** x ** y (x to the y power)
Modulo % x % y (the remainder of x/y)
Comparison Operators
Greater than > x > y (x is greater than y)
Less than < x < y (x is less than y)
Equal to == x == y (x equals y)
Greater than or equal to >= x >= y (x is greater than or equal to y)
Less than or equal to <= x <= y (x is less than or equal to y)
Not equal to != or <> x != y, x <> y (x does not equal y)
Boolean Operators
and and x and y (if both are true, then the expression is true)
or or x or y (if either is true, then the expression is true)
not not not x (if x is false, then the expression is true)
Assignment Operator
Assignment = X = 15
name = “Jim”
c01.indd 6
c01.indd 6 6/2/08 12:03:09 PM
6/2/08 12:03:09 PM
40. Chapter 1: A Python Primer
7
Expressions and Statements
Expressions and statements are the building blocks of Python programs. They are the equivalent of
phrases and sentences in English. To understand Python, it’s critical to understand how to put these
building blocks together.
Expressions
Expressions consist of combinations of values, which can be either constant values, such as a string
(“Jim”) or a number (12), and operators, which are symbols that act on the values in some way.
The following examples are expressions:
10 - 4
11 * (4 + 5)
x - 5
a / b
Operator Precedence in Expressions
When you have a multiple expression like 5 + 4 * 7, which operation is done first, the addition or the
multiplication? If it isn’t too painful to recall your high school algebra class, you might remember
learning the rules of operator precedence. These kinds of complex expressions require a set of rules
defining which expressions are executed first.
The following list describes the basic rules of operator precedence in Python (don’t worry if you don’t
understand all the terms right now; they’ll be explained as you need them):
Expressions are evaluated from left to right.
Exponents, multiplication, and division are performed before addition and subtraction.
Expressions in parentheses are performed first.
Mathematical expressions are performed before Boolean expressions (AND, OR, NOT)
Statements
The statement is the basic unit of programming. In essence, it says “do this to this.” Statements in Python
are not delimited by a visible character, such as the semicolon in C or C#. Every time you press Enter and
start a new line, you are entering a new statement.
❑
❑
❑
❑
c01.indd 7
c01.indd 7 6/2/08 12:03:10 PM
6/2/08 12:03:10 PM
41. Chapter 1: A Python Primer
8
For example, if you type:
Print 12 + 15
into the Python interpreter, you’ll get the following output:
>>> print 12 + 15
27
>>>
This is because you told the system to “print the result of the expression 12 + 15,” which is a complete
statement.
However, if you type:
print 12 +
you’ll get a syntax error, as shown here:
>>> print 12 +
SyntaxError: invalid syntax
>>>
Clearly, the system cannot read this because it isn’t a complete statement, so it results in an error.
Multi-line Statements
It is possible to have a single statement span multiple lines. You could do this for aesthetic reasons or
simply because the line is too long to read on one screen. To do this, simply put a space and a backslash
at the end of the line. Here are a few examples:
name = “Jim
Knowlton”
sum = 12 +
13
Iteration and Decision-Making
There are two basic ways to control the flow of a program: through iteration (looping) and through
decision-making.
c01.indd 8
c01.indd 8 6/2/08 12:03:10 PM
6/2/08 12:03:10 PM
42. Chapter 1: A Python Primer
9
Iteration
Iteration in Python is handled through the “usual suspects”: the for loop and the while loop. However,
if you’ve programmed in other languages, these seemingly familiar friends are a little different.
For Loops
Unlike in Java, the for loop in Python is more than a simple construct based on a counter. Instead, it is a
sequence iterator that will step through the items of any sequenced object (such as a list of names, for
instance). Here’s a simple example of a for loop:
>>> names = [“Jim”, “Joe”]
>>> for x in names:
print x
Jim
Joe
>>>
As you can see, the basic syntax is for <variable> in <object>:, followed by the code block to be
iterated.
While Loops
A while loop is similar to a for loop but it’s more flexible. It enables you to test for a particular
condition and then terminate the loop when the condition is true. This is great for situations when you
want to terminate a loop when the program is in a state that you can’t predict at runtime (such as when
you are processing a file, and you want the loop to be done when you reach the end of the file).
Here’s an example of a while loop:
>>> counter = 5
>>> x = 0
>>> while x < counter:
print “x=”,x
print “counter = “, counter
x += 1
x = 0
counter = 5
x = 1
counter = 5
x = 2
counter = 5
x = 3
counter = 5
x = 4
counter = 5
>>>
c01.indd 9
c01.indd 9 6/2/08 12:03:10 PM
6/2/08 12:03:10 PM
43. Chapter 1: A Python Primer
10
Break and Continue
As with C, in Python you can break out of the innermost for or while loop by using the
break statement. Also as with C, you can continue to the next iteration of a loop by using
the continue statement.
What about switch or case?
Many of you familiar with other programming languages are no doubt wondering
about a decision-tree structure similar to C’s switch statement or Pascal’s case.
Unfortunately, you won’t find it in Python. However, the conditional if-elif-else
structure, along with other constructs you’ll learn about later, make their absence not
such a big deal.
Decision-Making
When writing a program, it is of course critical to be able to evaluate conditions and make decisions.
Having an if construct is critical for any language, and Python is no exception.
The if Statement
The if statement in Python, as in other languages, evaluates an expression. If the expression is true,
then the code block is executed. Conversely, if it isn’t true, then program execution jumps to the end.
Python also supports use of zero or more elif statements (short for “else if”), and an optional else
statement, which appears at the end if you also have elif statements, and would be the “default”
choice if none of the if statements were true.
Here’s an example:
>>> name = “Jim”
>>> if name == “Jim”:
print “your name is Jim”
elif name == “Joe”:
print “your name is Joe”
else:
print “I have no idea what your name is”
your name is Jim
>>>
c01.indd 10
c01.indd 10 6/2/08 12:03:11 PM
6/2/08 12:03:11 PM
44. Chapter 1: A Python Primer
11
Functions
In many ways, the principle behind a function is analogous to turning on a TV. You don’t have to
understand all the electronics and communications technology behind getting the TV signal to your
receiver in order to operate the TV. You do have to know some simple behaviors, however, such as how
to turn it on, where the volume switch is, and so on. In a similar fashion, a function gives the program an
interface through which it can run program code without knowing the details about the code being run.
Defining a Function
You define a function in Python with the following simple syntax:
def functionName(paramenter1, parameter2=default_value):
<code block>
return value (optional)
Note two elements in the preceding example:
Parameters — As you can see, parameters can simply be a variable name (making them required
as part of the function call), or they can have a default value, in which case it is optional to pass
them in the function call.
The return statement — This enables the function to return a value to the code that called it. The
nice thing about this is that you can run a function and assign its output to a variable.
Here’s an example of a function definition:
>>> def getname(name):
return name + “ is very hungry”
>>>
Calling a Function
To call a function, simply enter the function name with the function signature:
functionName(paramenter1, parameter2)
If a parameter has a default value in its definition, then you can omit that parameter when you call the
function, and the parameter will contain its default value. Alternately, you can override the default value
by entering the value yourself when you call the function.
❑
❑
c01.indd 11
c01.indd 11 6/2/08 12:03:11 PM
6/2/08 12:03:11 PM
45. Chapter 1: A Python Primer
12
For example, if a function were defined as follows:
def jimsFunc(age, name = “Jim”):
Then you could call the function in any of the following three ways:
jimsFunc(23)
jimsFunc(42, “James”)
jimsFunc(42, firstName=”Joe”)
In the first example, I simply took the default value for the first parameter; in the second, I replaced it
with “James.”
Modules
A module is the highest-level programming unit in Python. A module usually corresponds to a program
file in Python. Unlike in Ruby, modules are not declared — the name of the *.py file is the name of the
module. In other words, basically each file is a module, and modules import other modules to perform
various programming tasks.
Importing Modules
Importing modules is done with either the import or reload command.
Import
To use a module, you import it. Usually import statements occur at the beginning of the Python
module. Importing modules is a fairly simple operation, but it requires a little explanation. Consider the
following examples:
1. import os
2. import os, sys
3. from os import getcwd
4. import os as operatingSystem
These examples highlight some variations in how you can import modules:
1. This first example is the simplest and easiest to understand. It is merely the keyword import
followed by the module name (in this case, os).
2. Multiple modules can be imported with the same import command, with the modules
separated by a comma.
c01.indd 12
c01.indd 12 6/2/08 12:03:11 PM
6/2/08 12:03:11 PM
46. Chapter 1: A Python Primer
13
3. You can import specific names only within a module, without importing the whole module, by
using the from <module> import <name> statement. This can be useful for performance
reasons if you only need one function from a large module.
4. If a module has a name that’s difficult to work with or remember, and you want to use a name
to represent it that is meaningful to you, simply use the as keyword and import <module> as
<identifier>.
Reload
Reload is another very useful command, especially when entering code within the Python interactive
interpreter. It enables you to reload a particular module without reloading Python. For example, if you
wanted to reload the os module, you would simply enter reload os.
If you’re wondering why you would ever want to do that, one scenario would be if you have a Python
script that runs all the time and it accesses a module on another machine. Assuming you always want to
ensure that you’re running the most current version of the remote module you’re accessing, you’d use
the reload command.
How Python Finds Modules to Load
When you use an import statement, you don’t tell Python where the module that needs to be loaded
is located. How, then, does it know where to find the file? The answer to that question is the module
search path.
The Module Search Path
Python has a predefined priority specifying where it should look for modules, known as the module
search path. When you enter an import command and the name of the module, Python checks the
following locations in the order shown here:
1. The home directory — This is either the directory from which you launched the Python
interactive interpreter or the directory where the main Python program is located.
2. PYTHONPATH — This is an environment variable set in the system. Its value is a list of
directories, which Python will search for modules.
3. Standard library directories — The directory in which the standard libraries are located are
searched next.
c01.indd 13
c01.indd 13 6/2/08 12:03:11 PM
6/2/08 12:03:11 PM
47. Chapter 1: A Python Primer
14
Exploring sys.path
If you ever want to see your system’s Python search path, all you have to do is bring up the interactive
interpreter, import the sys module, and type sys.path. The full Python module search path will be
returned, as shown in the following example:
>>> import sys
>>> sys.path
[‘C:Python25’, ‘C:Python25Libidlelib’, ‘C:Program FilesPythonNet’,
‘c:scriptspython’, ‘c:python25’, ‘C:Python25pyunit-1.4.1’,
‘c:python25pamie’, ‘C:WINDOWSsystem32python25.zip’, ‘C:Python25DLLs’,
‘C:Python25lib’, ‘C:Python25libplat-win’, ‘C:Python25liblib-tk’,
‘C:Python25libsite-packages’, ‘C:Python25libsite-packageswin32’,
‘C:Python25libsite-packageswin32lib’, ‘C:Python25libsite-
packages
Pythonwin’, ‘C:Python25libsite-packageswx-2.8-msw-ansi’]
>>>
Classes
Python is a language that can support both procedural programming and object-oriented programming.
Here is an example of a Python class:
>>> class name1():
def setmyname(self, myname):
self.name = myname
>>> jimname = name1()
>>> jimname.setmyname(“Jim”)
>>> print jimname.name
Jim
>>>
Note some points about Python’s implementation of class programming as demonstrated in the
preceding example:
If we were inheriting from other classes, those class names would have been inside the
parentheses of the class name1(): definition.
In this case, there is one class method, setmyname. If we wanted to create a constructor for the
class, it would be named __init__ .
To create an instance of a class, you simply assign a variable to the class definition, as in
jimname = name1() .
Attributes are accessed with familiar dot notation (instance variable.attribute) such as
jimname.name .
❑
❑
❑
❑
c01.indd 14
c01.indd 14 6/2/08 12:03:12 PM
6/2/08 12:03:12 PM
48. Chapter 1: A Python Primer
15
Summary
This chapter provided a brief tour of the Python language, including the following highlights:
How to get up and running with Python
Python’s lexical structure
Operators, expressions, and statements
Iteration and decision-making
Functions and modules
Classes and object-oriented programming
Of course, there is much more to the Python language than what this short chapter has outlined.
Much of it you’ll discover as you work through the projects in this book.
Let’s get started!
❑
❑
❑
❑
❑
❑
c01.indd 15
c01.indd 15 6/2/08 12:03:12 PM
6/2/08 12:03:12 PM
52. Directory/File
Snapshot Program
Have you ever installed a program and wanted to know exactly what was installed? Programs
typically include numerous files and directories — in some cases hundreds. It can be difficult to
determine what was put on the system. This can especially be important if, for instance, you are
verifying an install to ensure that all the directories and files were placed on the system.
Conversely, with an uninstall, you want to verify just the opposite –– that everything that had been
put on the system is now gone.
The File/DirectoryComparison program enables you to create a “snapshot” of your system based
on a directory “base” you provide. It will also perform a comparison of two snapshots to show you
the differences. This includes items missing from snapshot 1 but in snapshot 2, and items missing
in snapshot 2 but present in snapshot 1.
Along the way, you’ll learn several valuable things about Python and its features:
How to create and import modules
How to create and call functions
Getting user input and passing the value provided by the user to the program
How to find information related to the Python Standard Library
❑
❑
❑
❑
c02.indd 19
c02.indd 19 6/2/08 12:05:25 PM
6/2/08 12:05:25 PM
53. Part I: The Projects
20
Using the Program
You can find the program located on the www.wrox.com page for this book. To run it, simply go to a
command prompt, and from the directory on your system where the Chapter 2 program files are located,
type the following: python snapshot.py.
This will bring up a menu like the one shown here:
DIRECTORY/FILE COMPARISON TOOL
====================================
Please type a number and press enter:
1. Create a snapshot
2. List snapshot files
3. Compare snapshots
4. Help
5. Exit
From here, you can create a snapshot, compare two snapshots, view some help text (always a good
idea!), or exit the program. The following sections describe each of the program features.
Creating a Snapshot
There are two scenarios for which you would create a snapshot:
You haven’t created a snapshot yet and want to create one to have a “base” to compare against
later.
You have created a snapshot and have run some process (such as an install or uninstall) and
want to compare it to the first snapshot you created.
In both cases, the interface is the same. When you type 1 and press Enter to create a snapshot, you are
prompted for some information the program needs to create it. First, you’ll get the following prompt:
Enter the directory name to create a snapshot of:
This prompt is asking you for the “root” on which to base your snapshot. For instance, if I were
installing a program into the normal Windows location (which is C:Program Files), which creates a
directory called jimsprogram, for this prompt I would initially type C:Program Files because I want
to know anything that was put into that directory. That way, when my program installs, I can see what
has been put into there.
❑
❑
c02.indd 20
c02.indd 20 6/2/08 12:05:25 PM
6/2/08 12:05:25 PM
54. Chapter 2: Directory/File Snapshot Program
21
After I tell the directory to “snap,” I get the following prompt:
Enter the name of the snapshot file to create:
In other words, it is creating a file on disk, with the snapshot. This is not a human-readable file (it’s a
“Pickle” file — more on that later), but Python will be able to read it and use it to compare snapshots.
You can give it any valid filename for your system.
Snapshot Filenames
Because you can look up snapshot filenames by extension, it makes sense to use an
extension you can remember, and to be consistent. I suggest naming your snapshots
with a .snp extension, as that isn’t used for any other type of common file.
Your snapshot is now created. Pressing Enter will take you back to the menu.
Listing Snapshot Files
If you type 2 and press Enter, you’ll be presented with an option to list the snapshot files in your current
directory. Snapshot files can have any valid filename, so you’ll be prompted as follows in order for
Python to determine how to list the files:
LIST SNAPSHOT FILES
====================================
Enter the file extension for your snapshot files
(for example, ’snp’ if your files end in ‘.snp’):
After you enter the common extension for your snapshot files, you’ll be presented with a list similar to
the following (except with your own files listed, of course):
Snapshot list:
========================
ci_directory.snp
ci_directory2.snp
doctemp1.snp
doctemp2.snp
Press [Enter] to continue...
As noted in the preceding sidebar, don’t forget to name all your snapshot files with a consistent
extension.
Pressing Enter will take you back to the menu.
c02.indd 21
c02.indd 21 6/2/08 12:05:25 PM
6/2/08 12:05:25 PM
56. "Hush! Barbe, don't call!" entreated Sandy.—
p. 168.
"Good, pure, true, and strong," she settled; "and," as a sudden
conviction struck her, "she is beautiful, like her mother was ten years
ago. Dressed"—her thoughts following along the same way as
Charity's—"well, she would be a success. She is wasted on Mr.
Warde. Shall I interfere?"
She was so deep in thought, working out a sudden plan, that she did
not notice when Marjorie ceased playing.
Marjorie, glancing at her, asked softly—
"Was that too sad? Shall I try something else?"
But in a moment the Duchess rose briskly, and put her hand kindly
on Marjorie's shoulder.
"No, my dear. I shouldn't like that spoiled by anything else. Mr.
Warde is right. You have a gift. But a girl like you should not be sad
57. or—or perplexed. Forgive an old woman. Is something troubling
you?"
Marjorie looked up into the keen eyes above her.
"Not troubling," she hesitated, "only things are sometimes
perplexing."
As she spoke her eyes travelled to the window, through which came
the sound of low-voiced chatter and delicate laughter. The older
woman, looking at the girl, saw a sudden arrested look come into
her eyes and, following their direction, was again puzzled. Charity,
standing by Mrs. Bethune's chair, was smiling up into Mr. Pelham's
face. She had the manner of one who is pleased, and who wishes to
please, and her pretty daintiness of pose and dress was very
attractive. Mr. Pelham's whole attention, as he conversed, was given
to her. In his courteous attitude were expressed, in the eyes of the
two lookers-on, both deference and admiration.
"That girl has grown very pretty," the Duchess said, "and Mr. Pelham
seems to think so. He is quite an acquisition here, though I am
amused to hear you sniffed at him at first."
"Yes," agreed Marjorie, a little pang at her heart.
The keen eyes travelled back again to Marjorie's face.
"But your mother was prettier than any of you. The sweetest,
merriest creature ever seen, with you babies at her feet. I am glad
to see her so much better, able to do even this little, poor soul, poor
soul!"
The sudden tears welled up into Marjorie's eyes at the appreciation
and tenderness of the tone.
"And, my dear—forgive an old woman again—but I think I have
guessed Mr. Warde's hopes for a long time, and he is a good man.
There, there"—as Marjorie's face grew agitated—"nothing could have
happened better. Your mother will have you at hand, and though she
is so unselfish and brave, she has missed you sadly; and there is
plenty of money."
58. Marjorie listened in silence, with a feeling as though chains were
being bound round her. As she walked back by the Duchess's side to
her mother's chair she strove in vain to recall her courage. In the
eyes of the man who watched her, as she came towards him, the
shadow on her face had deepened with that little excursion into the
house.
59. CHAPTER VI.
A MIDNIGHT VISIT.
The boys had seized the opportunity of the attention of their elders
being engaged elsewhere to get into mischief. Although they had
made so much fuss about their right of way to school, it was not the
only way they used. They had, in fact, several ways. One was by
train to Baskerton, a village on the river five miles away, and thence,
by lanes and the parks, home. This, however, required time and the
absence of authorities. Another way was through Easton and the
parks, up the course of the little stream, which at one point nearly
touched the Court gardens. In this stream, its shallow waters
splashing up against their ankles, the boys were walking, and the
baby was prancing between them.
"Should we take Barbe with us?" David had asked, pausing on the
Green.
"If we can get her," Sandy had replied.
The boys reconnoitred, and the piercing whistle, which set the baby
all a-quiver with expectation, sounded through the garden.
"There then, go!" said nurse somewhat crossly, as Barbe began to
stamp; and she went. Her education was proceeding apace. Her
father sometimes listened aghast at the things which, in her baby
prattle, she reported herself to have done.
"See, Barbe, there's a rat!" Sandy said eagerly, as a flop and a
splash made them jump. "See, it's swimmin' away."
"'Wimmin' away," said the baby, stooping to look, her two hands on
her two knees, and the front of her frock sailing on the water before
her.
60. "Oh, Barbe, you're all wet!" David said, as they landed, and strolled
up the field.
"Wet!" she echoed delightedly. "Foots—f'ock!"
"You'll have to be dried."
"I know," said Sandy cheerfully; "we'll dry you by the Bishop's fire—
almost sure to be a fire."
But the study window, to which they crept warily by sheltered ways,
was shut. The Bishop was absent.
"Now what's to be done?" said David.
"I know where there's a fire," Sandy said. "Was this morning, 'cos of
that lead. Let's take her to the little room."
Again they slipped by leafy ways out of the Palace garden into the
cathedral yard. The baby's wet skirts flopped round her, and David
lifted her into his arms.
The approach of Mrs. Lytchett, returning from the Deanery in
unwonted bravery of attire, prompted them to seek refuge behind a
tomb. Here it took the boys' whole attention to prevent Barbe's
chatter drawing unwished-for notice upon them.
"Hush! Barbe, don't call!" entreated Sandy.
"Barbedie good girl," announced the baby in a loud voice, lifting
herself on tip-toe to see the passer-by.
Mrs. Lytchett's ears were good, and, besides, she felt certain at this
point that her eyes had seen something fluttering. She stepped off
the pathway, and examined a tomb near.
"Hush!—sh—sh!" cautioned David, holding up his finger to his mouth
—a movement which so pleased Barbe that she proceeded to copy
it.
Mrs. Lytchett passed on; the danger was over. David lifted up the
baby and carried her into a little octagon room near by, built in the
wall of the cathedral, and used frequently as a workroom or office.
61. Here the boys were at home. It was the head-quarters of their
greatest friends—the masons engaged on the renovations always in
progress at the cathedral.
In the grate were the slowly dying embers of a fire, and the room
was empty.
"Mr. Galton ain't locked up yet, knowed he wouldn't," said Sandy.
"He likes his tea punctual—'spects it's time. Now, Barbe, come an'
get done."
Whilst David was holding the baby to the fire, Sandy disappeared,
presently returning with an excited face.
"They've nearly done," he said. "It's prime up there. Seems to me,
we'd best settle as soon as possible."
"This baby won't get dry," said David, gloomily. "Just look at her!"
"I know," said Sandy, regarding the bedraggled Barbe. "We'll take it
off an' leave it here. An' I'll fetch her somefink. Sure to be somefink
stored in Margie's basket—know Orme made holes in himself last
week."
So it happened that it was a little blue girl—clad in one of Orme's
shabbiest overalls—who met Mrs. Bethune's returning chair, and was
lifted to her knee for a "yide."
"But what has happened? where are her own clothes?" Mrs. Bethune
asked, recognising the substitute.
"We thought they were just a little damp," said Sandy in explanation,
climbing up the back of the chair to kiss his mother.
"Good boy, Sandy!" said his mother, "to take care of her."
"But how did they get damp?" asked Marjorie suspiciously.
"Just a little water p'raps got on them," he replied, feeling the tone
unkind after his mother's praise.
"Then you have been in mischief?" asked Marjorie.
62. "Barbedie walked in er water," the baby replied, as if she had been
doing a good work.
"You shouldn't have let her," Mrs. Bethune said caressingly.
"Barbe don't want lettin'," answered Sandy philosophically. "She
does wivout."
The sweets of mischief whetted the boys' appetites for more. They
applied themselves with zeal to a work they had in hand, and for the
next few days little was seen of them.
One evening they were standing in a disused corner of the Palace
grounds, under the ruined window of the old banqueting hall, which
formed part of the wall enclosing the gardens of the modern wing of
the house. The corner where they stood was immediately adjoining
the wall of their own garden, and was part of an overgrown
shrubbery between the ruins and the parks.
Both boys were exceedingly dirty. Faces, capless heads, fingers,
clothes, all bore traces of the underground work from which they
had just emerged. They had burrowed from their cave, and were
mightily pleased at their point of exit. No place could be more
secluded, nor less likely to be discovered. And from the ruined wall
close by, under the shelter of a spreading elder, they were able to
drop easily either into the cathedral yard or the Bishop's garden.
"Now the game begins. We've got a base of operations," said David
grandly.
"How much?" asked Sandy.
"What you work from, and what you fall back upon, if you get
besieged. And it's a good base too," he added, looking round.
"We've got to make this passage hard and firm, and then hide it
from that prying gardener."
"An' we can pay back Mrs. Lytchett," said Sandy with joy.
63. "How?"
"Oh, I know! She just hates us going to the Bishop's window. He
told me he'd just got a new tin of gingerbread, an' now we can get
in wivout goin' through the gate. She's made that gate so it clicks."
"But you mustn't let her see."
"Not me! If she comes, we'll just run round the house, and she'll fink
we've come back way. And then she'll run round to catch us, an' we
shan't be there."
Sandy spoke with the certainty of much experience, as, indeed, he
had a right to do.
"Our character is all gone," David said thoughtfully, "so it don't much
matter how bad we are."
"No, s'long as it ain't wicked bad. We'll be highwaymen, but we
won't be thieves and robbers."
"We can get into the cathedral, too," suggested David.
And then, with minds full of revolution and anarchy, the boys bent
earnestly to the preliminary work of making their passage secure.
"Ross and Orme, you're never to go along there without us," David
said to his young brothers, when he had wriggled back to the cave
whence his passage started. Now their services were no longer
needed, they were felt to be rather nuisances.
"If you do, you'll get smacked right hard," said Sandy.
Both children fixed round eyes on their elders, unable to understand
this sudden change. They were dismayed at its injustice. For some
days they had been treated with indulgent kindness, all their faults
overlooked, so long as they did diligent work. They were cleaned
when possible, and consoled when their dirty appearance awoke
wrath in the powers responsible for them. Now, it seemed, all was
changed. There was no mistaking Sandy's attitude, as he stood
ready to administer the smacks alluded to. Nor were David's
frowning brows more encouraging.
64. Ross tried argument. "We'se scooped, too," he said. "We'se got dirty,
ever so," he added.
"Ever so," echoed Orme.
"No matter! You kids must do as you're bid, and if ever you go a
step along there you'll catch it. See?" said David. And the infants,
with moody brows, averred that they saw.
By this time the hole which formed the entrance to the cave was
much improved. The wooden steps had been replaced by a flight of
mud steps, the making of which had been a joy, not only to the
boys, but to the baby. They had required water as well as mud in
their making—endless paddlings and pattings and treadings down of
little feet before the staircase was complete. David had engineered
the proceedings, and Mr. Warde, now and then hovering about the
top, had conferred advice. He was not encouraged to descend. The
boys wanted no prying grown-ups to mar their schemes. Marjorie,
now and then, had suspicions that some extra mischief was afloat.
Never before had she known them to stick to anything for so long.
But she recollected the fascination of caves and holes, and was,
besides, much engaged with her own concerns.
65. The Bishop and the boy.
—p. 170.
One evening the Bishop, on leaving the drawing-room, had gone to
his study. It had been a wet day, and the rain had finished in a
thunderstorm an hour or so before, leaving the sky washed and
pellucid under the summer moon.
The shutters had been closed and a little fire lighted; but presently,
finding the room warm, the Bishop opened the window, and stood
gazing over the wide lawn which occupied the space between the
house and the ruins.
The delicate tracery of the ruined window of the banqueting hall,
and the many unevennesses of the walls, stood out black against the
sky. Every object on the lawn—every bush and tree and flower—was
sharply distinct.
As he looked, his eye caught a movement among the distant shrubs.
Some small object was advancing along the gravelled walk
surrounding the lawn. Presently, as if attracted by the light, it turned
off the pathway on to the lawn, in a bee-line for the window.
The Bishop stood watching, wondering a little, when the object
resolved itself first into a small boy, and then into Sandy Bethune.
"Why, Sandy!" he exclaimed, "how did you get here?"
"Is it the middle of the night?" asked Sandy in his usual cheerful
way.
"Nearly. It's half-past eleven. Good gracious! What have you been
doing?"
For, on approaching the light, Sandy was seen to be covered with
mud and otherwise much disarrayed.
Sandy considered. He was in a deep fix—so deep a one as to
threaten the upheaval and overthrow of some well-laid plans, just on
the point of being carried out. The Bishop was an understanding
man. Sandy had confided in him before, and knew his worth. If only
66. Mrs. Lytchett did not live at the Palace, and spoil everything, Sandy
would have been quite willing to share that residence with the
Bishop. He had once told the Bishop so, artlessly asking when Mrs.
Lytchett was going away to live elsewhere. The Bishop, on his side,
found the children of his friend very charming, specially so
irrepressible Sandy; and was ready to be lenient when their
peccadilloes were in question. He now invited Sandy in, despite the
muddy covering which encased him from head to foot. Sitting down,
he began to question him gravely.
"What is it, Sandy? Why are you in such a mess?"
Sandy sat down on a little stool, as if glad to present his small
person to the fire, and said, "It's the bovering funderstorm. We'd
never thought of that. An' we got caught, an' had to take shelter, an'
when we got back our way was bunged up—all squashy with mud.
An' we hadn't got no spades nor fings out with us. So at last I said I
would go and scout—you know—an' then I saw you."
"Who's 'we'?" asked the Bishop.
"Me an' David."
"And how did you get into my garden?"
"Oh, over the wall. We're highwaymen, and we've got a way of our
own."
"Indeed. And where's David now?"
"Oh, he's over there, all muddy, tryin' to clean himself. He's a deal
worse than me," said Sandy cheerfully.
"He must indeed be bad, then. What do you propose to do?"
"That's it. We can't get back to the pantry window now our way's
gone," said artless Sandy. "Not in at all, not wivout knockin' at the
door. I did think p'raps"—persuasively—"you cud come and knock."
"I see. And then?"
67. "Then, when you was talkin' to father, we cud slip in. Don't fink
father would see—not to notice."
"How long have you been highwaymen?" the Bishop asked.
"On'y about a week—and this is a sickener," said Sandy disgustedly.
"We was ghosts for a bit at first—till a woman screeched so we
nearly got caught, stupid fing!"
And the Bishop, remembering certain reports that had been made to
him, was pleased with his acumen in refusing to call in the police.
"If I were you, I should try a better line of business," he said.
"Ghosts frighten silly women, and highwaymen are not very
creditable, on the whole."
"Yes," agreed Sandy. "We're goin' to. Next we're goin' to be pioneers
and settlers."
"Ah, I see. And where are you going to settle?"
Sandy's bright eyes were turned suspiciously to the kind ones
looking down upon him. He fidgeted uneasily, and a smile came
across the Bishop's face.
"I see," he said. "Perhaps you have not yet made up your minds."
Sandy looked uncomfortable. "Not 'zactly," he confessed. "Truth is, it
depends—I don't fink Dave would like me to tell. It's such a grand
plan," he went on enthusiastically, "it 'ud be such a pity——"
"To have it spoilt. Well, don't get into more mischief than you can
help," the Bishop cautioned, "and don't do anything to make your
mother uneasy."
"Mother? Oh, mother'll laugh—she always does. You see, the bother
is," confided Sandy, "there ain't no places to pioneer—every bit's
taken. An' we've on'y just thought on it; an' it's splendid. We want a
girl badly, though. Margie? No, Margie's no good. Settlers has wives
an' squaws," went on Sandy pensively, "and we've on'y got Barbe
lately, an' she's aw'fly little. 'Sides, you have to take such care on her
—she's the on'y one Mr. Pelham's got. There's a lot of us, but mother
68. says she cudn't spare not the littlest bit of one. So much less him his
one, an' such a little one. It's a 'sponsibility," sighed Sandy, "when
you want to do fings."
Through the open window came the musical sound of the chimes
from the cathedral. The Bishop, with a quick sigh, rose.
"There is a quarter to twelve. Your father will be going to bed. Fetch
David quickly."
"Should fink he's cleaned by now," said Sandy hopefully. "He was
rubbin' himself wiv the leaves off the trees—drippin' wet."
Mr. Bethune opened his front door in response to a low knocking,
which at first he did not hear. His eyes had the unseeing, far-away
look in them of a man disturbed in a possessing line of thought. The
red light in the hall shone on the face of the Bishop, who entered
and stood on the doormat for a minute, in such a position as to
shield the entrance of the two muddy boys.
"Here is the Guardian for you," he said, "with a very appreciative
notice of your paper." Then he went on, "And tell Marjorie to-morrow
morning not to be too cross with the state of the boys' clothes.
They've been in mischief, but it won't happen again—not the same
sort."
69. The father pretended not to hear
the scuffling of small feet.
The two men looked at one another and laughed, and the father
pretended not to hear the scuffling of small feet upon the stairs. The
Bishop went home with no weight on his conscience—only a little
pathetic envy of the man he had just left. Somehow those stifled
scufflings up the stairs had gone straight to the depths of his very
tender and lonely heart.
"The Bishop knows all 'bout it," excused Sandy sturdily, when
confronted by Marjorie the next morning.
70. "The Bishop knows that all your clothes are in the bath, with both
taps running!"
"Well, he does," Sandy repeated, "proberly. He said we were the
out-an'-outest dirtiest little grubs he'd ever seen."
"That you are—no one will contradict him. But he couldn't know that
your clothes were in the bath."
"Yes, he would. If they were so dirty, where else could they be? It's
all that 'gustin' funderstorm."
"Thunderstorm!" echoed Marjorie suspiciously. "That was at ten
o'clock. What has that got to do with your clothes and the Bishop?"
"Tell you it has. You'd best ask him, if you don't b'lieve me," said
Sandy, hurt at her unbelief. "Anyhow, he does know that they was
dirty. An' just cos we want to save trouble an' wash 'em ourselves,
you're cross an' spiteful. Girls are no good—'cept little uns. What's
there to put on? Best be somefink old, cos there's a deal of diggin' to
be done."
"I shall stop that digging if you make such a mess of yourselves."
"You'd best not," said David meaningly, from his bed in the further
corner. "If you do, you'll be sorry," he said darkly.
END OF CHAPTER SIX.
72. Three Songs of Birth
A Christmas Sermon
By the Rev. Hugh Miller, M.A.
"Suddenly there was with the angel a multitude of the heavenly host praising God,
and saying, Glory to God in
the highest, and on earth peace, good will toward men."—St. Luke ii. 13, 14.
Three times are we told in Scripture that the angels sang.
At the birth of the world, when the foundations of the
earth were laid, the morning stars sang together and all
the sons of God shouted for joy. When Jesus was born
into the world a multitude of the heavenly host praised God and
said, "Glory to God in the highest, and on earth peace, good will
toward men." And when anyone is born again there is joy among the
angels in heaven over the sinner that repenteth. The subject of the
song in each case is the same: the leading motif of them all is man.
Man, to begin with, was God's chief end in creation, and the angels
sang not so much because a new world had been made, but rather
because a new being akin to themselves was put into it, to whom
they might minister and with whom they might co-operate in the
doing of God's most holy will; and this season comes to remind us of
our inherent dignity in God's sight, of the noble ideal He has formed
for us, of the value He sets on those whom He sent His Son to seek
and to save. As God made us and as He intends us to be, we are not
a little higher only than the animals, we are rather only "a little lower
than the angels." He has crowned us with glory and honour and set
us over the work of His hands. He has put all things under our feet.
The material universe was made for man, to be his home, to develop
his powers, to be a test and discipline of his moral character. I refuse
to be reduced to the same rank, or to be placed in the same order,
73. as the beasts that perish. Remembering the angels' first song, I
assert my supremacy.
And man is most of all supreme because God has given him the
freedom to choose the objects of his life, and the means by which
he can secure them. Sun, moon and stars are bound by laws which
they cannot transgress. The movements of the animals are guided
by impulses and instincts over which they have no moral control. To
man alone belongs the power of refusing to bow before God's
greatness and of disobeying God's commands. Man only has this
sovereignty; but his sovereignty led to his servitude, and the chains
that bound him were forged by an angel who fell before man's fall.
If, then, all the angels worshipped and adored when man was made
with the great gift of free choice, how must the holy ones that
remained after the first and great apostasy have grieved when the
fallen angels took man along with them in their fall! For because of
man's disobedience God's idea in making man seemed to be
thwarted and the peace and good will to which he was called
appeared no longer possible. Instead of being the master of
creation, he was now to a large extent its unhappy victim.
We know from hints thrown out here and there in Scripture with
what absorbing interest the angels followed the plans of God to
bring order once more out of the chaos caused by sin, and the effort
He put forth to create a new heaven and a new earth, wherein
dwelleth righteousness. No wonder, then, that when the fulness of
the time was come, and God sent His Son, made of a woman, made
under the law to redeem man, the angels should have sung a
second time, and anticipated for man at last a happy time of peace
and good will.
The angels had a clear perception of the purpose of Christ's coming.
One of the chief of them said to Joseph, "Thou shalt call His name
Jesus: for He shall save His people from their sins." And they all sang
when He came, because they knew that God was now dealing in a
special and most effective way with that dark thing which cast its
shadow on heaven as well as on earth. And it becomes us to
74. remember that it is the sin of man which in the mind of God and His
holy angels is associated with the coming of Jesus Christ. To this end
was He born, and for this cause came He into the world.
The sin of our first parents had passed on from generation to
generation, and each one of the millions of mankind had to say,
"Behold, I was shapen in iniquity; and in sin did my mother conceive
me"; and each fulfilled in his own life all too truly the sad promise of
his birth. How was the tradition to be broken, and yet broken by one
who really belonged to the race? The instincts of man himself
foreshadowed the truth. Stories of a virgin birth here and there
discernible in paganism show the deep intuition which was realised
in Jesus Christ. He came into the world to fight with sin, to redeem a
race steeped in a terrible heritage of evil, and that He might redeem
it He Himself was born, and yet was free from evil.
He fought sin and He conquered it. Why, then, has the angels' song
not been fulfilled? Why does sin still cast its shadow on earth and
heaven alike? Why does God's loving purpose in sending His Son
seem still to suffer so wide defeat? Because in his recovery as in his
fall, man's will must play its part. I can only be saved from sin when
I will to be saved; I only become a partaker of the benefits which
Christ brought from heaven to earth when, yielding to the inspiration
of the Holy Spirit, I turn with full accord to Jesus Christ as my
Saviour. Marvel not, therefore, that we say to you with peculiar
emphasis on the day in which Christ was born, "Ye must be born
again." Otherwise, His birth is of no avail to you and me. We are not
honouring Him, we are putting Him rather to an open shame, if we
keep out of our thoughts at this time the supreme purpose of His
coming, if we are not personally dealing with Him even now as to
the burden and guilt of our sin.
But we can set the angels a-singing in the sky, and the melody of
their music can be felt in our own hearts, if we turn in lowly
penitence to Him who came to save His people from their sins, and
to quicken them to a new life of righteousness and peace and joy.
Only when a man comes to himself in lowly penitence, and then
75. goes to his Father with a lofty faith, does he enter into the full
purpose of his manhood; and only then, also, is there not only joy
among the angels in heaven over the sinner that thus repenteth, but
there is music and dancing on the earth as well, and the old life
ends in which sin reigned, and the new begins in which Christ
reigns; and His reign means "Glory to God in the highest, and on
earth peace, good will to men."
"There is no peace, saith my God, to the wicked."
76. O Wondrous Night!
A NEW CHRISTMAS CAROL.
Words by Arthur Bryant. Music by Charles Bassett.
1. O wondrous night! O wondrous night! we fain would
tell
The news the Angel told;
The holy vision which befel
The Shepherds by their fold.
With fear they saw, with gladness heard
The heav'nly minstrelsy,
With hope each trembling heart was stirred
At that sweet harmony: ...
"We bring good news Which ne'er shall cease;
To God be praise, to God be praise,
On earth be peace."
2. O wondrous sight! O wondrous sight for simple
swains,
With hasty steps who sped;
The music of those joyous strains
To that poor manger led.
With awe they gazed on Christ the Lord
Amid that happy throng,
And Israel at His feet adored,
Taught by the Angels' song: ...
"We bring good news, Which ne'er shall cease;
To God be praise, to God be praise,
On earth be peace."
77. 3. O wondrous night! they homeward turned
To where their flocks did lay,
And sang the song they late had learned
To cheer them on their way.
The timid dawn began to peer
Across the dewy wold;
Their lips in accents loud and clear
The gladsome tidings told:
"We bring good news," &c.
4. O wondrous sight, that God should live
In robe of flesh for man!
O wondrous Love, Himself to give
When closed His mortal span!
Sing, O ye skies! be joyful, earth!
Ye winds, bear o'er the seas
The news of blessèd Jesu's birth,
And those sweet harmonies:
"We bring good news," &c.
78. THE HOUSE COMFORTABLE.
By Lina Orman Cooper, Author of "The House Beautiful," Etc.
The House Beautiful must needs be also the House
Comfortable, if we take true loveliness to consist of
perfect fitness for service. Thoroughness is the keynote
of each. In order to strike it we must have entered heart
and soul into Ruskin's translation of St. Ursula's Room.
Carpaccio himself painted the useful in the beautiful in this famous
picture. From the princess's book, set up at a slope fittest for
reading, to the shelf which runs under the window, providing a place
to put things on—from a silver lamp on the white wall to the little
blue slippers beside her bed, each detail ensures comfort of the first
quality.
Comfort is a thing quite apart from fashion. So it is easier to indicate
the road which leads to the House Comfortable than it was to point
out details in the House Beautiful. We most of us agree about the
essentials required for real comfort: chairs upon which you can sit
fearlessly; beds which rest and do not bruise; arms that support
without cramping; pokers that bend not; strong tables and sharp
knives, these are a sample of the things I mean. But true comfort
depends on more than surface surroundings. It is indissolubly linked
with attention to detail. The houses to which guests return time after
time is the one in which soap is never absent from its tray, and
where pillows are not only covered with frilled slips, but also stuffed
with down and interlined with soft covering in place of waxed
ticking.
I would say, first of all, that the House Comfortable must stand in a
sunny situation. This ensures warmth and light, without which our
bodies are ill-nourished and miserable. "Where the sun never comes
the doctor does" is a much-to-be-quoted proverb. We cannot all live
79. exactly where we like. Circumstances of business, and means,
generally determine locality. But common-sense must guide us in the
selection of our houses. If we would be really comfortable, we must
live in light, dry, airy, and clean homes. Never take a house on the
sole recommendation of its pretty appearance. To have a really
beautiful house we must first see that it is essentially built for
comfort. The really useful and good is generally ornamental, for it
possesses the realistic beauty of fitness. A north and south aspect
for the chief sitting rooms, with east and west windows, secures
both sunshine and shade. We want afternoon coolness as well as
morning light. If our apartment looks towards the sun rising, heavy
curtains should be ready to draw when east wind rages. A stick to
effect this noiselessly is a small boon much appreciated. If our
casement faces the golden gates of the west, no such protection is
called for. But all windows should have double blinds—white outside,
to absorb heat, and dark inside, to veil the sun when necessary. The
comfort of lying in bed, facing a dark green blind can only be
estimated by those who have reluctantly been disturbed by the too
early shafts of the god Phœbus.
There should be a triple water supply in the House Comfortable;
ewers always filled from the soft-water pump. Every well and tank
should be tested ere we take up residence. Pure water, and plenty of
it, is essential to the health (and therefore comfort) of every
household. It should be perfectly clear and bright, and free from
taste or smell. Yet impurity may lurk even in the most sparkling
water. Therefore science must decide as to its desirability. If only
iron or lime water is procurable, jars of lump ammonia, or a bottle of
cloudy liquid ammonia, a bag of oatmeal or a bundle of bran should
lie on every washstand. The hot-water boiler not only supplies
unlimited baths, but may be devised to heat the house. In every
Canadian home a stove in the cellar warms the rooms above by
means of drums and fans. We might do much the same in England
with our hot-water pipes. These should certainly run through the
linen-press and clothes cupboards, and terminate in bathroom
spirals. On these, towels and rough sheets could be dried and aired.
80. A face cloth always warm is one of the luxuries in our House
Comfortable.
After sanitation, ventilation takes its place in the home. How to
secure a constant supply of fresh air is a question which demands
most serious consideration. In ages past, houses were
unintentionally ventilated by the ill-fitting doors and window-frames,
wide chimneys, and open fire-places. But in our modern buildings
comfort is secured by almost air-tight doors and windows.
Ventilators at the top of such are delightful and necessary for real
comfort, or a Queen Anne casement may have a swing in its upper
frame. It is not always easy, however, to secure exemption from
draught in our modern mansions. When the brick-and-mortar fiend
has placed door, window, and fireplace exactly opposite each other,
screens must be judiciously used. A brass rod from which hangs a
curtain, screwed into the door jamb and suspended by a tiny chain
from the ceiling, is a good thing, or an ordinary portière may be
allowed. The former plan, however, enables us to keep the door
open without feeling a wind.
Padded stair-carpets secure noiseless ascent in the House
Comfortable. Cork mats by the big bath are welcome to bare feet.
Many cupboards are a necessity. A place for everything and
everything in its place is one of the initial rules for everyone's
comfort. It is also Divine law. Hanging presses, medicine cupboards,
butler's pantry, housemaid's closets, keep dresses from dust, poisons
from the unwary, silver and glass intact, and brushes unworn.
The House Comfortable must not be over-servanted. Neither must it
be undermanned. Of the two evils, the latter is preferable, as the
mistress herself then looks after the minutiæ of her house. With all
deference to Matthew Prior, comfort does not flow on a line with
ignorance. It requires a cultivated intelligence to provide such in our
homes.
Education has done much for us on this point. How not to do it in
the House Comfortable is exemplified by the abodes of our
forefathers. Going over Beaumaris Castle the other day, I noted the
81. small apertures for exit; the high caverns of chimneys; the windows
of horn; the crooked stairs. Nowadays we find stoves and slow
combustion grates quite a necessity for comfort—whilst lofty ceilings,
broad staircases, and wide windows can be quite as picturesque,
and are far more to be desired.
The dictionary definition of the word "comfort" implies enlivenment
and capability for dispensing bodily ease. For this, moral qualities are
as necessary as well-planned, well-equipped houses.
Punctuality, for instance, is an ingredient required to secure a
comfortable home.
When breakfast and dinner are movable feasts, served up at the
whim of a lie-a-bed or a gad-about, they can only be make-believes,
after all. Cold coffee is unpalatable even when partaken of in a
sunny room. Whitey-brown sausages are unappetising unless piping
from the pot. Yet this—like all other virtues—may be strained too far.
Nothing is more uncomfortable than to feel no latitude is allowed to
a weary guest, or to find one's host at marmalade three minutes
after the time appointed for the disappearance of a savoury.
Courtesy in this must be our rule. Neatness is another necessity. No
house can be really comfortable that is littered with papers, or in
which boots lie in the drawing-room—yet finickiness in arrangement
makes the home unbearable. The most uncomfortable visit I ever
paid was to the most scientifically correct house. Chairs were not
allowed to touch the wall-paper; footstools never shifted. A towel for
wiping down the varnish of the bath was provided, and—I was made
miserable! By all means keep paint and paper in as much primitive
purity as possible, but let unobtrusive service guard these points.
Much more could I discourse of the House Comfortable, but space
forbids. Let me only remind you that the veriest cottage—plenished
with wisdom and lovingly provided—may fulfil all its conditions just
as well as the most luxurious castle.
83. DONKEY BOY To The QUEEN
A TRUE INCIDENT.
By Alfred T. Story
Part II.
A week passed before anything further was heard. Then a
summons came for Tam to appear before her Majesty
on the following afternoon. He was duly in attendance,
and had not long to wait before a man in Highland
costume came into the room where he was seated and
said—
"Noo, my braw laddie, her Most Gracious Majesty and his Royal
Highness the Prince Consort will come in through that door in twa
seconds. When they enter all you hae to dy is ta stan' up an' mak'
yer obeisance. An' when they ax ye a question jist ye say yes or nae,
your Majesty, or your Royal Highness, as the case may be. An' if
they ax ye naething—weel, jist ye say naething in return."
With these words the wise servitor withdrew. Barely had he gone out
of one door ere the other opened, and the same lady he had seen
before, leaning on the arm of the gentleman he likewise
remembered, appeared before friend Tam. They were both dressed
much more richly than when he had previously seen them, the lady
having a brilliant star on her breast, and the gentleman wearing a
silken sash over his shoulder.
For a moment the boy was confused, but he recovered himself
sufficiently to recollect that he had to make an "obeisance." He had
omitted to ask the Highland gentleman what that was, but he
84. thought it must be something like the soldier's salute, and so he
stood perfectly upright and saluted.
"So you have come, my lad, to see her Majesty about the position of
donkey-boy?" said the gentleman.
"Yes, sir—your Royal Highness," replied Tam. Only when he had got
out the word "sir" did it flash upon him that he was standing before
the Queen and her Royal Consort.
"Well, her Majesty has caused inquiries to be made about you, and
she finds that, although you are a little wayward and sometimes
disobedient to your grandparents, you are not on the whole a bad
boy."
"No, your Royal Highness," said Tam.
"Does that mean that you are not a bad boy, or that you do not
sometimes disobey your grandparents?"
This question, though backed by a genial smile, somewhat
disconcerted the would-be donkey-boy. He was silent for a moment,
then he answered, looking first at one and then at the other, with
that straight glance of his, "I hae sometimes been disobedient to my
grandparents, but I think I have learned better now."
"I am glad to hear that," said the Prince.
Then, speaking for the first time, the Queen said, "Well, Tam, if I
make you my donkey-boy, will you promise to be obedient to all my
slightest wishes and commands? Do not answer lightly. I am a
severe mistress in that I expect the strictest obedience and attention
to duty. But I, in return, am strict in doing my duty to those I
employ."
"And if you prove a worthy and trustworthy servant," added the
Prince, "your position is secure for life."
"Not, however, as a mere donkey-boy all your days," put in the
Queen with a smile.
85. Said Tam with a faltering tongue: "If ye'll try me, your Majesty, I'll do
my best, and," he added, as though struck with a sudden thought,
"I'll no need to lick the donkeys, 'cos I ken hoo ta mek 'em run
'thout the stick."
86. Yetta threw up her hands in
amaze.
"And how do you do that?" asked the Prince with a smile.
"I meks 'em carry a bunch o' thistles afore 'em."
"Well, we will see," replied her Majesty, smiling. "Now you may run
home and tell your grandparents you are to be ready to begin duty
this day week. But before you go you will see the gentleman who
spoke to you a minute or two ago."
With these words and a kindly smile the Sovereign and her Royal
Consort withdrew.
The one door closed, the other immediately opened, and again
entered the Highland gentleman. "Sae ye hae been engagit ta look
after ta cuddies, eh?" he questioned.
Tam said he had.
87. "Aweel, it's a verra guid step in life for a young callant to begin wi',
an' if ye tek heed there's nae telling whereto it may lead—ablins
even to the primiership, if ye ken what that is. For ye mun know, the
gift o' the heaven-made Prime Minister is just to ken hoo ta manage
a' th' human cuddies that are sent to Parliament to bother 'em. But
mebbe a' that's a wee bit abune yer understanding as yet, and sae
we'll just leave it an' speer aboot yer claes."
Needless to say how surprised Donal and Yetta were to hear Tam's
story, how thankful to reflect that their boy was to have such a start
in life. He reported to them what had been said, and the promise he
had given, and they believed that, like the Jamison he was, he would
be true to his word. All the same, they did not omit to pray for that
guidance and support for him without which his own efforts would
be vain.
The evening before Tam's week was up a parcel was delivered at
Jamison's door, addressed to his grandson. It contained a complete
new suit, as the Highland gentleman had said, "from the skin
outwards." Never was seen such a brave outfit, to Tam's thinking. He
turned it over and admired it, article by article, for at least a couple
of hours, but would not try it on, or any part of it, until he had had a
good wash. The tub was never a thing he was shy of, but on this
occasion it was used as though he intended to wash out his every
fault, as well as all the merely superficial smuts and stains that had
accumulated, so as to appear before his Queen a spotlessly clean
cuddy-tender.
When the operation was completed, Tam indued himself in his new
garments and went on parade, so to speak, before his grandmother.
Yetta was busy stirring the matutinal porridge when he walked into
the ben and said:
"How do I look, granny?"
Yetta, turning round, threw up her hands in amaze. She hardly knew
him, so great was the transformation effected by the new clothes
and the scrubbing he had given himself. Donal was no less surprised
88. when he came in from his morning milking. Tam looked two inches
taller and a lot sprucer.
"Ye mind me of yer puir father," said the old man as he sat down to
breakfast.
That was a note of sad recollection which brought tears to Yetta's
eyes; but a smile was soon gleaming through them when Tam,
getting sight of Meg, who was eyeing him as it were askance, said
drily, "Meg looks as if she hardly kenned what ta mek of her
handiwark; for the beginning o't was a' her doing."
Just then the noise of wheels was heard on the road, and as the
messenger who brought the clothes left word that one of the
Queen's carriages would pick him up on the morrow, Tam thought
surely this was the one. But it was not. Indeed, he ran to the door at
least twenty times ere, towards eleven o'clock, his vehicle arrived. It
was a quaint affair, half carriage, half wash-basket, drawn by two
asses, creatures as beautiful of their kind as could be found. It was
driven by her whom he knew, and by her side were several bright
little faces, while the Highland gentleman, riding behind on one
pony, as sturdy and Hielan' as himself, led another by the bridle.
Donal and Yetta came out and with bowed heads thanked the
august though simple-hearted lady for the great kindness she had
shown to their boy. She replied with a kindly smile:
"There appears to be the making of a good man in him, and, with
God's help, we will do our best to make him one."
Little more was said, and, mounting the led pony, Tam rode off by
the side of the faithful retainer, who never got further away from the
carriage than the dust raised by its wheels.
Thus commenced Tam's career in life. Though he served the noblest
lady in the land, he did not find his way one altogether of buttered
89. parsnips and cream. The one thing abhorrent to his royal mistress
was idleness and indifference. The motto of her establishment—of all
her establishments—was "The diligent eye." In this principle she
found not only the best interests of her own house, but the best
interests also of those who served her.
Tam could not be called idle, nor could he be called exactly
indifferent; but during the years of his tending of cattle and sheep
on the brae-side he had got into the habit of liking to loll about, to
saunter and dream, and then to make up, or try to make up, the
leeway of work or duty by a spurt of energy. Another fault he had
was to leave things about—for others to "side" or put in order. This
arose, no doubt, from the narrow dimensions of his home, where
there was hardly room for everything to have its particular place. It
was, however, neither a very grievous nor a deeply rooted fault; and
a little sharp drilling, not unfrequently at the hands of the Highland
gentleman—a sort of major of the household, who possessed "the
diligent eye" par excellence—soon corrected Tam's delinquency in
this regard.
But the other fault was more deeply rooted and cost the young
donkey-boy many a bad quarter of an hour. Indeed, on one occasion
it nearly cost him his place. He had been given a task to do, and in
place of doing it with all diligence he had been found with his feet
growing to the ground, as it were. The consequence was an
interview with the Highland gentleman, who told him, "Tam, ye have
either ta pe punisht or to leave her Majesty's service: which shall it
pe?"
"I'll tek the punishment, sir, if you please," he answered.
"Tam, ye are a wise poy, an' we'll mebby mek a man o' ye yet," said
the major-domo.
Tam took his punishment, and was the better for it; but he still failed
to come up to his royal mistress's ideal of a servant. Like his fellow-
servitors, he had plenty of time for rest and recreation: hours of
labour were by no means long. So much time had he, indeed, for
90. himself, that the Highland gentleman put suitable books before him,
and counselled him to improve his mind by reading and study. He
failed, however, to profit by the advice, and was presently made
aware of his error by a violent thunder-clap.
He was in attendance on his royal mistress one day, when she and
the children were out for a drive. A poor body was met, in apparent
distress, by the wayside. Inquiry was made as to her condition,
present help was extended, and a promise of future beneficence
given if further investigation should warrant its bestowal. Hence the
necessity arose for an address to be written down, and Tam, who
was that day the only person in attendance, was requested to do it.
When Tam entered the royal service he could read a bit and write
very imperfectly; but there had been time, had he followed the
counsel given him, to have greatly improved himself in both those
accomplishments. Not having done so, he fumbled egregiously over
the task set him, and, in short, made such a hash of it that an eye of
wrath was turned upon him.
Tam had seen that eye in all its moods—of laughter and smiles, of
grief, of earnestness, of affection, even of solemnity and awe, but he
had never as yet beheld it flash in indignant wrath. He felt as though
the muscles of his knees had been cut away and the ground was
sinking from under his feet. What would he not have given to be
miles away! But he had to face the storm, and it came in this way:
"Were not books and paper and ink put before you? And were you
not advised to improve your reading and writing?"
Tam falteringly admitted that such was the case.
"Why did you not attend to the advice?"
"I—I——" stammered the ease-loving Tam.
"Had you not the time?"
"Yes."
"Then why did you not do as you were wished?"
91. Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com