100% found this document useful (2 votes)
19 views

Download Complete An Introduction to Python Programming for Scientists and Engineers Johnny Wei-Bing Lin PDF for All Chapters

The document promotes the ebook 'An Introduction to Python Programming for Scientists and Engineers' by Johnny Wei-Bing Lin, which focuses on teaching Python through practical examples from various scientific disciplines. It emphasizes a hands-on approach with exercises and online resources to aid learning for beginners. Additionally, it includes recommendations for other related ebooks available for instant download.

Uploaded by

simmsgazzayt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
19 views

Download Complete An Introduction to Python Programming for Scientists and Engineers Johnny Wei-Bing Lin PDF for All Chapters

The document promotes the ebook 'An Introduction to Python Programming for Scientists and Engineers' by Johnny Wei-Bing Lin, which focuses on teaching Python through practical examples from various scientific disciplines. It emphasizes a hands-on approach with exercises and online resources to aid learning for beginners. Additionally, it includes recommendations for other related ebooks available for instant download.

Uploaded by

simmsgazzayt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

An Introduction to Python Programming for


Scientists and Engineers Johnny Wei-Bing Lin

https://ebookmeta.com/product/an-introduction-to-python-
programming-for-scientists-and-engineers-johnny-wei-bing-
lin/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Introduction to Python for Engineers and Scientists: Open


Source Solutions for Numerical Computation 1st Edition
Sandeep Nagar
https://ebookmeta.com/product/introduction-to-python-for-engineers-
and-scientists-open-source-solutions-for-numerical-computation-1st-
edition-sandeep-nagar/
ebookmeta.com

Introduction to Scilab: For Engineers and Scientists 1st


Edition Sandeep Nagar

https://ebookmeta.com/product/introduction-to-scilab-for-engineers-
and-scientists-1st-edition-sandeep-nagar/

ebookmeta.com

Introduction to Octave: For Engineers and Scientists 1st


Edition Sandeep Nagar

https://ebookmeta.com/product/introduction-to-octave-for-engineers-
and-scientists-1st-edition-sandeep-nagar/

ebookmeta.com

Serial Sabotage 1st Edition Carolyn Keene

https://ebookmeta.com/product/serial-sabotage-1st-edition-carolyn-
keene/

ebookmeta.com
Yard Birds The Lives and Times of America s Urban Chickens
First Edition Philip Levy

https://ebookmeta.com/product/yard-birds-the-lives-and-times-of-
america-s-urban-chickens-first-edition-philip-levy/

ebookmeta.com

Swaiman’s Pediatric Neurology. Principles and Practice 6th


Edition Kenneth F. Swaiman

https://ebookmeta.com/product/swaimans-pediatric-neurology-principles-
and-practice-6th-edition-kenneth-f-swaiman/

ebookmeta.com

Handbook of Pediatric Epilepsy Case Studies 2nd Edition


Maria Augusta Montenegro

https://ebookmeta.com/product/handbook-of-pediatric-epilepsy-case-
studies-2nd-edition-maria-augusta-montenegro/

ebookmeta.com

Electrophysiological Recording Techniques 2nd Edition


Robert P Vertes Editor Timothy Allen Editor

https://ebookmeta.com/product/electrophysiological-recording-
techniques-2nd-edition-robert-p-vertes-editor-timothy-allen-editor/

ebookmeta.com

Prince Musical Icon 1st Edition Stephanie Watson

https://ebookmeta.com/product/prince-musical-icon-1st-edition-
stephanie-watson/

ebookmeta.com
Joseph Portraits Through the Ages 1st Edition Alan T.
Levenson

https://ebookmeta.com/product/joseph-portraits-through-the-ages-1st-
edition-alan-t-levenson/

ebookmeta.com
An Introduction to Python Programming for
Scientists and Engineers

Python is one of the most popular programming languages, widely used for data analysis
and modelling, and is fast becoming the leading choice for scientists and engineers. Unlike
other textbooks introducing Python, typically organised by language syntax, this book uses
many examples from across Biology, Chemistry, Physics, Earth science, and Engineering to
teach and motivate students in science and engineering. The text is organised by the tasks
and workflows students undertake day-to-day, helping them see the connections between
programming tools and their disciplines. The pace of study is carefully developed for complete
beginners, and a spiral pedagogy is used so concepts are introduced across multiple chapters,
allowing readers to engage with topics more than once. “Try This!” exercises and online
Jupyter notebooks encourage students to test their new knowledge, and further develop their
programming skills. Online solutions are available for instructors, alongside discipline-specific
homework problems across the sciences and engineering.

Johnny Wei-Bing Lin is an Associate Teaching Professor and Director of Undergraduate


Computing Education in the Division of Computing and Software Systems at the University
of Washington Bothell, and an Affiliate Professor of Physics and Engineering at North Park
University. He was the founding Chair of the American Meteorological Society’s annual
Python Symposium.

Hannah Aizenman is a Ph.D. candidate in Computer Science at The Graduate Center, City
University of New York. She studies visualization and is a core developer of the Python
library Matplotlib.

Erin Manette Cartas Espinel graduated with a Ph.D. in physics from the University of
California, Irvine. After more than 10 years at the University of Washington Bothell, she
is now a software development engineer.

Kim Gunnerson recently retired as an Associate Teaching Professor at the University of


Washington Bothell, where she taught chemistry and introductory computer programming.

Joanne Liu received her Ph.D. in Bioinformatics and Systems Biology from the University of
California San Diego.
“This book provides an excellent introduction to the Python language especially targeted at those
interested in carrying out calculations in the physical sciences. I especially like the strong coverage of
graphics and of good coding practice.”
Raymond Pierrehumbert, University of Oxford

“An excellent introduction to Python for scientists and engineers. Much more than teaching you how to
program with Python, it teaches you how to do science with Python.”
Eric Shaffer, University of Illinois at Urbana-Champaign

“Python has achieved an essential role in many disciplines within science, engineering, and beyond.
Students and professionals are expected to be fluent in it, and (as I see in my daily job of helping users of a
high-performance computing facility) they often struggle to reach that fluency. The authors have succeeded
in the daunting task of writing a single book to help people reach a very advanced level of fluency, starting
very gently and assuming no background. Unlike other books on the subject, An Introduction to Python
Programming for Scientists and Engineers focuses on teaching for the intended end goal of scientists and
engineers – investigating their scientific problems – not writing software for its own sake. I am looking
forward to working with the generation who will learn how to program in Python using this book!”
Davide Del Vento, NCAR Computational & Information Services Laboratory

“An Introduction to Python Programming for Scientists and Engineers introduces programming in Python
using evidence-based approaches to active learning. The exercises help both students and instructors
identify misconceptions in programming, allowing students to build a strong foundation in Python
programming. The book streamlines content such that there is a focus on mastering immediately useful
concepts, normalizing errors, and demonstrating recovery.”
Kari L. Jordan, Executive Director, The Carpentries
An Introduction to Python
Programming for Scientists
and Engineers

Johnny Wei-Bing Lin


University of Washington Bothell and North Park University

Hannah Aizenman
City College of New York

Erin Manette Cartas Espinel


Envestnet Tamarac

Kim Gunnerson
University of Washington Bothell

Joanne Liu
Novozymes A/S
University Printing House, Cambridge CB2 8BS, United Kingdom

One Liberty Plaza, 20th Floor, New York, NY 10006, USA

477 Williamstown Road, Port Melbourne, VIC 3207, Australia

314-321, 3rd Floor, Plot 3, Splendor Forum, Jasola District Centre,


New Delhi – 110025, India

103 Penang Road, #05–06/07, Visioncrest Commercial, Singapore 238467

Cambridge University Press is part of the University of Cambridge.

It furthers the University’s mission by disseminating knowledge in the pursuit of


education, learning, and research at the highest international levels of excellence.

www.cambridge.org
Information on this title: www.cambridge.org/highereducation/isbn/9781108701129
DOI: 10.1017/9781108571531

© Johnny Wei-Bing Lin, Hannah Aizenman, Erin Manette Cartas Espinel,


Kim Gunnerson, and Joanne Liu 2022

This publication is in copyright. Subject to statutory exception


and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2022

Printed in the United Kingdom by TJ Books Limited, Padstow Cornwall

A catalogue record for this publication is available from the British Library.

Library of Congress Cataloging-in-Publication Data


Names: Lin, Johnny Wei-Bing, 1972– author. | Aizenman, Hannah, 1987– author. |
Espinel, Erin Manette Cartas, 1965– author. | Gunnerson, Kim Noreen, 1965– author. |
Liu, Joanne (Joanne K.), author.
Title: An introduction to Python programming for scientists and engineers /
Johnny Wei-Bing Lin, University of Washington, Bothell, Hannah Aizenman,
City College of New York, Erin Manette Cartas Espinel, Envestnet Tamarac,
Kim Gunnerson, University of Washington, Bothell, Joanne Liu, Biota Technology Inc.
Description: First edition. | Cambridge, United Kingdom ; New York, NY :
Cambridge University Press, 2022. | Includes bibliographical references and index.
Identifiers: LCCN 2022000136 | ISBN 9781108701129 (paperback)
Subjects: LCSH: Python (Computer program language) | Computer programming. |
Engneering–Data processing. | BISAC: SCIENCE / Earth Sciences / General
Classification: LCC QA76.73.P98 L55 2022 | DDC 005.13/3–dc23/eng/20220304
LC record available at https://lccn.loc.gov/2022000136

ISBN 978-1-108-70112-9 Paperback

Cambridge University Press has no responsibility for the persistence or accuracy


of URLs for external or third-party internet websites referred to in this publication
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Contents

Detailed Contents page vii


Preface xvii
To the Student xxiii
Notices and Disclaimers xxvi
Acknowledgments xxix

Part I Getting Basic Tasks Done 1


1 Prologue: Preparing to Program 3

2 Python as a Basic Calculator 8

3 Python as a Scientific Calculator 27

4 Basic Line and Scatter Plots 52

5 Customized Line and Scatter Plots 88

6 Basic Diagnostic Data Analysis 124

7 Two-Dimensional Diagnostic Data Analysis 176

8 Basic Prognostic Modeling 209

9 Reading In and Writing Out Text Data 261

10 Managing Files, Directories, and Programs 327

Part II Doing More Complex Tasks 353

11 Segue: How to Write Programs 355

12 n-Dimensional Diagnostic Data Analysis 365

13 Basic Image Processing 394

v
vi Contents

14 Contour Plots and Animation 439

15 Handling Missing Data 483

Part III Advanced Programming Concepts 503


16 More Data and Execution Structures 505

17 Classes and Inheritance 536

18 More Ways of Storing Information in Files 570

19 Basic Searching and Sorting 595

20 Recursion 633

Part IV Going from a Program Working to Working Well 655


21 Make It Usable to Others: Documentation and Sphinx 657

22 Make It Fast: Performance 666

23 Make It Correct: Linting and Unit Testing 683

24 Make It Manageable: Version Control and Build Management 693

25 Make It Talk to Other Languages 702

Appendix A List of Units 706

Appendix B Summary of Data Structures 708

Appendix C Contents by Programming Topic 709

Glossary 719
Acronyms and Abbreviations 726
Bibliography 727
Index 729
Detailed Contents

Preface page xvii


To the Student xxiii
Notices and Disclaimers xxvi
Acknowledgments xxix

Part I Getting Basic Tasks Done 1


1 Prologue: Preparing to Program 3
1.1 What Is a Program and Why Learn to Program? 3
1.2 What Is Python and Why Learn This Language? 5
1.3 Software We Will Need 6

2 Python as a Basic Calculator 8


2.1 Example of Python as a Basic Calculator 8
2.2 Python Programming Essentials 10
2.2.1 Expressions and Operators 10
2.2.2 Variables 13
2.2.3 The Python Interpreter 15
2.3 Try This! 18
2.4 More Discipline-Specific Practice 24
2.5 Chapter Review 24
2.5.1 Self-Test Questions 24
2.5.2 Chapter Summary 25
2.5.3 Self-Test Answers 26

3 Python as a Scientific Calculator 27


3.1 Example of Python as a Scientific Calculator 27
3.2 Python Programming Essentials 28
3.2.1 Using Prewritten Functions 29
3.2.2 Importing Modules and Using Module Items 30
3.2.3 Writing and Using Our Own Functions 32
3.2.4 A Programmable Calculator 35
3.2.5 Python Interpreter and Code-Writing Environments for
More Complex Programs 38
3.3 Try This! 41

vii
viii Detailed Contents

3.4 More Discipline-Specific Practice 47


3.5 Chapter Review 47
3.5.1 Self-Test Questions 47
3.5.2 Chapter Summary 48
3.5.3 Self-Test Answers 49

4 Basic Line and Scatter Plots 52


4.1 Example of Making Basic Line and Scatter Plots 52
4.2 Python Programming Essentials 54
4.2.1 Positional Input Parameters for Required Input 55
4.2.2 Introduction to Lists and Tuples 58
4.2.3 Introduction to Strings 62
4.2.4 Introduction to Commenting and Jupyter Markdown 66
4.3 Try This! 69
4.4 More Discipline-Specific Practice 81
4.5 Chapter Review 81
4.5.1 Self-Test Questions 81
4.5.2 Chapter Summary 83
4.5.3 Self-Test Answers 85

5 Customized Line and Scatter Plots 88


5.1 Example of Customizing Line Plots 88
5.2 Python Programming Essentials 91
5.2.1 Optional Input into Functions Using Keyword Input Parameters 91
5.2.2 Customizing How the Plot Looks 93
5.2.3 Handling Multiple Figures or Curves 96
5.2.4 Adjusting the Plot Size 97
5.2.5 Saving Figures to a File 98
5.2.6 Introduction to Array Calculations 99
5.2.7 The Concept of Typing 103
5.3 Try This! 106
5.4 More Discipline-Specific Practice 117
5.5 Chapter Review 117
5.5.1 Self-Test Questions 117
5.5.2 Chapter Summary 119
5.5.3 Self-Test Answers 121

6 Basic Diagnostic Data Analysis 124


6.1 Example of Basic Diagnostic Data Analysis 124
6.2 Python Programming Essentials 126
6.2.1 More on Creating Arrays and Inquiring about Arrays 128
6.2.2 More on Functions on Arrays 132
Detailed Contents ix

6.2.3 Going Through Array Elements and an Introduction to Loops 134


6.2.4 Introduction to Asking Questions of Data and Branching 139
6.2.5 Examples of One-Dimensional Loops and Branching 148
6.2.6 Docstrings 153
6.2.7 Three Tips on Writing Code 155
6.3 Try This! 158
6.4 More Discipline-Specific Practice 170
6.5 Chapter Review 170
6.5.1 Self-Test Questions 170
6.5.2 Chapter Summary 171
6.5.3 Self-Test Answers 173

7 Two-Dimensional Diagnostic Data Analysis 176


7.1 Example of Two-Dimensional Diagnostic Data Analysis 176
7.2 Python Programming Essentials 182
7.2.1 The Shape of Two-Dimensional Arrays 183
7.2.2 Creating Two-Dimensional Arrays 184
7.2.3 Accessing, Setting, and Slicing in a Two-Dimensional Array 186
7.2.4 Array Syntax and Functions in Two-Dimensional Arrays 190
7.2.5 Nested for Loops 191
7.3 Try This! 194
7.4 More Discipline-Specific Practice 203
7.5 Chapter Review 203
7.5.1 Self-Test Questions 203
7.5.2 Chapter Summary 205
7.5.3 Self-Test Answers 207

8 Basic Prognostic Modeling 209


8.1 Example of a Basic Prognostic Model 209
8.2 Python Programming Essentials 217
8.2.1 Random Numbers in Computers 217
8.2.2 Scalar Boolean Type and Expressions 221
8.2.3 Nested Branching 230
8.2.4 Looping an Indefinite Number of Times Using while 232
8.2.5 Making Multiple Subplots 236
8.2.6 More on Nested Loops 237
8.2.7 Conditionals Using Floating-Point Numbers 239
8.3 Try This! 241
8.4 More Discipline-Specific Practice 252
8.5 Chapter Review 252
8.5.1 Self-Test Questions 252
8.5.2 Chapter Summary 254
8.5.3 Self-Test Answers 257
x Detailed Contents

9 Reading In and Writing Out Text Data 261


9.1 Example of Reading In and Writing Out Text Data 262
9.2 Python Programming Essentials 267
9.2.1 Introduction to Objects 268
9.2.2 Arrays as Objects 269
9.2.3 Lists as Objects 277
9.2.4 Strings as Objects 280
9.2.5 Copying Variables, Data, and Objects 286
9.2.6 Reading and Writing Files 290
9.2.7 Catching File Opening and Other Errors 298
9.3 Try This! 300
9.4 More Discipline-Specific Practice 317
9.5 Chapter Review 317
9.5.1 Self-Test Questions 317
9.5.2 Chapter Summary 319
9.5.3 Self-Test Answers 321

10 Managing Files, Directories, and Programs 327


10.1 Example of Managing Files, Directories, and Programs 328
10.2 Python Programming Essentials 331
10.2.1 Filenames, Paths, and the Working Directory 332
10.2.2 Making and Removing Empty Directories 335
10.2.3 Moving and Renaming Files and Directories 337
10.2.4 Copying and Deleting Files and Directories 338
10.2.5 Listing the Contents of a Directory 340
10.2.6 Testing to See What Kind of “File” Something Is 341
10.2.7 Running Non-Python Programs in Python 342
10.3 Try This! 343
10.4 More Discipline-Specific Practice 347
10.5 Chapter Review 347
10.5.1 Self-Test Questions 347
10.5.2 Chapter Summary 348
10.5.3 Self-Test Answers 350

Part II Doing More Complex Tasks 353


11 Segue: How to Write Programs 355
11.1 From Blank Screen to Program: A Process to Follow 355
11.2 The Importance of Testing 360
11.3 The Importance of Style Conventions 363
Detailed Contents xi

12 n-Dimensional Diagnostic Data Analysis 365


12.1 Example of n-Dimensional Diagnostic Data Analysis 365
12.2 Python Programming Essentials 367
12.2.1 The Shape of and Indexing n-Dimensional Arrays 368
12.2.2 Selecting Subarrays from n-Dimensional Arrays 370
12.2.3 Array Syntax and Functions in n-Dimensional Arrays 372
12.2.4 Reshaping n-Dimensional Arrays and Memory Locations of Array
Elements 374
12.2.5 Subarrays and Index Offset Operations 376
12.2.6 Triple Nested Loops and Mixing Array Syntax/Selection and Looping 378
12.2.7 Summary Table of Some Array Functions 380
12.3 Try This! 382
12.4 More Discipline-Specific Practice 386
12.5 Chapter Review 387
12.5.1 Self-Test Questions 387
12.5.2 Chapter Summary 389
12.5.3 Self-Test Answers 391

13 Basic Image Processing 394


13.1 Example of Image Processing 394
13.2 Python Programming Essentials 400
13.2.1 Reading, Displaying, and Writing Images in Matplotlib 401
13.2.2 Boolean Arrays 404
13.2.3 Array Syntax and Functions and Asking Questions of Data in Arrays 408
13.2.4 Performance of Looping and Array Syntax and Functions 414
13.2.5 The NumPy reduce Method 416
13.2.6 Looping Through Lists of Objects 417
13.3 Try This! 419
13.4 More Discipline-Specific Practice 430
13.5 Chapter Review 431
13.5.1 Self-Test Questions 431
13.5.2 Chapter Summary 432
13.5.3 Self-Test Answers 434

14 Contour Plots and Animation 439


14.1 Example of Making Contour Plots and Animations 440
14.2 Python Programming Essentials 445
14.2.1 An Introduction to Matplotlib’s Object API 446
14.2.2 Line and Shaded Contour Plots 451
14.2.3 Using cartopy to Overlay Maps 453
14.2.4 Basic Animation Using Matplotlib 456
14.2.5 Flexible Functions and Dictionaries 459
xii Detailed Contents

14.3 Try This! 465


14.4 More Discipline-Specific Practice 477
14.5 Chapter Review 477
14.5.1 Self-Test Questions 477
14.5.2 Chapter Summary 479
14.5.3 Self-Test Answers 481

15 Handling Missing Data 483


15.1 Example of Handling Missing Data 483
15.2 Python Programming Essentials 487
15.2.1 Approach 1: Define a Data Value as Missing and Process
with Boolean Arrays or Expressions 488
15.2.2 Approach 2: Use Series and IEEE NaN Values 490
15.2.3 Approach 3: Use Masked Arrays 492
15.2.4 Which Approach Is Better? 493
15.3 Try This! 494
15.4 More Discipline-Specific Practice 498
15.5 Chapter Review 498
15.5.1 Self-Test Questions 498
15.5.2 Chapter Summary 499
15.5.3 Self-Test Answers 501

Part III Advanced Programming Concepts 503


16 More Data and Execution Structures 505
16.1 Example of Using More Advanced Data and Execution Structures 505
16.1.1 Solution 1: Explicitly Call Functions and Store Results in Variables 506
16.1.2 Solution 2: Explicitly Call Functions and Store Results in Arrays 507
16.1.3 Solution 3: Explicitly Call Functions and Store Results in Dictionaries 508
16.1.4 Solution 4: Store Results and Functions in Dictionaries 509
16.2 Python Programming Essentials 511
16.2.1 More Data Structures 511
16.2.2 More Execution Structures 519
16.2.3 When to Use Different Data and Execution Structures 521
16.3 Try This! 523
16.4 More Discipline-Specific Practice 529
16.5 Chapter Review 530
16.5.1 Self-Test Questions 530
16.5.2 Chapter Summary 531
16.5.3 Self-Test Answers 533
Detailed Contents xiii

17 Classes and Inheritance 536


17.1 Examples of Classes and Inheritance 536
17.1.1 Scientific Modeling Example 537
17.1.2 Scientific Bibliography Example 544
17.2 Python Programming Essentials 546
17.2.1 Defining and Using a Class 546
17.2.2 Inheritance 550
17.2.3 More Sophisticated Sorting Using sorted 553
17.2.4 Why Create Our Own Classes? 554
17.2.5 Automating Handling of Objects and Modules 557
17.3 Try This! 560
17.4 More Discipline-Specific Practice 564
17.5 Chapter Review 564
17.5.1 Self-Test Questions 564
17.5.2 Chapter Summary 566
17.5.3 Self-Test Answers 568

18 More Ways of Storing Information in Files 570


18.1 Examples of Using Other File Formats 570
18.2 Python Programming Essentials 576
18.2.1 Excel Files 576
18.2.2 pickle Files 578
18.2.3 netCDF files 579
18.3 Try This! 583
18.4 More Discipline-Specific Practice 589
18.5 Chapter Review 589
18.5.1 Self-Test Questions 589
18.5.2 Chapter Summary 590
18.5.3 Self-Test Answers 592

19 Basic Searching and Sorting 595


19.1 Examples of Searching and Sorting 595
19.2 Python Programming Essentials 598
19.2.1 Summary of Some Ways to Search and Sort 598
19.2.2 Searching and Sorting Algorithms 601
19.2.3 Basic Searching and Sorting Using pandas 611
19.3 Try This! 622
19.4 More Discipline-Specific Practice 628
19.5 Chapter Review 628
19.5.1 Self-Test Questions 628
19.5.2 Chapter Summary 629
19.5.3 Self-Test Answers 631
xiv Detailed Contents

20 Recursion 633
20.1 Example of Recursion 633
20.2 Python Programming Essentials 635
20.2.1 Using the walk Generator 635
20.2.2 Recursion and Writing Recursive Code 637
20.2.3 More Applications of Recursion 642
20.3 Try This! 645
20.4 More Discipline-Specific Practice 649
20.5 Chapter Review 649
20.5.1 Self-Test Questions 649
20.5.2 Chapter Summary 650
20.5.3 Self-Test Answers 651

Part IV Going from a Program Working to Working Well 655


21 Make It Usable to Others: Documentation and Sphinx 657
21.1 Introduction 657
21.2 Principles of Documenting 657
21.3 General Convention for Docstrings: The NumPy Format 659
21.4 The Sphinx Documentation Generator 660

22 Make It Fast: Performance 666


22.1 Introduction 666
22.2 Preliminaries 666
22.2.1 Describing the Complexity of Code 666
22.2.2 Practices That Can Result in Inefficient Code 668
22.3 Finding the Bottlenecks Using Profilers 670
22.3.1 timeit 671
22.3.2 cProfile 672
22.3.3 line-profiler 674
22.3.4 memory-profiler 676
22.4 Fixing the Bottlenecks 678
22.4.1 Generators 678
22.4.2 Just-in-Time Compilation 680
22.5 Pitfalls When Trying to Improve Performance 682

23 Make It Correct: Linting and Unit Testing 683


23.1 Introduction 683
23.2 Linting 683
23.3 Unit Testing 686
23.3.1 unittest 687
23.3.2 pytest 688
23.4 The “Test-Driven Development” Process 690
Detailed Contents xv

24 Make It Manageable: Version Control and Build Management 693


24.1 Introduction 693
24.2 Version Control 693
24.2.1 Using Git as a Single User 694
24.2.2 Using Git as a User Who Is Part of a Collaboration 696
24.2.3 Using Git with Branching 697
24.3 Packaging 698
24.4 Build Management and Continuous Integration 699

25 Make It Talk to Other Languages 702


25.1 Introduction 702
25.2 Talking with Fortran Programs 702
25.3 Talking with C/C++ Programs 704

Appendix A List of Units 706

Appendix B Summary of Data Structures 708

Appendix C Contents by Programming Topic 709


C.1 Introductory Programming Topics 709
C.1.1 What Is a Program and General Elements of Python 709
C.1.2 Variables and Expressions 710
C.1.3 Typing and Some Basic Types 710
C.1.4 Strings 711
C.1.5 Functions 711
C.1.6 Branching, Conditionals, and Booleans 712
C.1.7 Looping 712
C.1.8 Console Input and Output 713
C.1.9 Text File Input and Output 713
C.1.10 Exceptions 713
C.1.11 Arrays 714
C.1.12 Classes 715
C.2 Intermediate Programming Topics 715
C.2.1 Abstract Data Types and Structures 715
C.2.2 Algorithm Analysis 716
C.2.3 Searching and Sorting 716
C.2.4 Recursion 717
C.3 Other Topics 717
C.3.1 How to Program and Programming Style 717
C.3.2 Distributions and Interactive Development Environments (IDEs) 717
Other documents randomly have
different content
Mrs. Meredith Jones and myself that we were all going to sleep
under that roof. Opp had examined the sky and predicted rain before
morning, and Miss Page was not equal to a return journey
—“doubling the road,” as they say here—even if any of us had
contemplated such a thing.
“Tom and I will sleep in the middle,” said Mrs. Meredith Jones
reassuringly to me, after an earnest conversation apart with her
husband, but I was immensely amused at the whole situation. We
were as helpless against certain circumstances as if we did not
possess sixpence between us; for it would have taken nearly a day
to build another camp and the guides were too tired to think of such
a thing. We were all stranded out in space, and there was nothing to
do but make the best of it.
About two hours after luncheon I felt as if I had had no exercise that
day and Opp suggested that I go up the mountain to see a gorge
locally famous. So, accompanied by Mr. N. and Latimer, I followed
him up the steepest and roughest mountain of my experience. There
was no trail. He trampled ahead through the brush and we followed.
Mr. Nugent preceded and literally pulled me up more than one
perpendicular place, but Opp insisted upon taking charge of me
through the slippery intricacies of a rocky stream. But we were
rewarded by the most beautiful spot I have yet seen. Imagine a
forest glade with five or six islands of rock—boulders so huge that no
other word will describe them. These islands were covered on all
sides with the richest moss and the most delicate ferns, and on the
top of each grew great trees, their long roots gripping the sides of the
rock like petrified pythons. Then a water-course choked with smaller
boulders, and rising out of it, straight up for five hundred feet, a solid
wall of rock crowned with a pine forest. The wall was a half-mile long
and so smooth that one could well imagine some terrible convulsion
of these Adirondacks during which a mountain had been split in
twain, one side grinding itself into these boulder-islands of the forest.
On high the tree-tops were so matted that the glade was filled with a
twilight almost green. One had the impression of walking under the
sea. Each of us selected a dry rock, and we sat there for an hour
telling mountain experiences. I had had one or two in the Alps,
extremely modest ones, but all the men looked at me with intense
admiration as I related them. American men seem to have an almost
passionate admiration for women of great physical endurance and
courage. Our men take it as a matter of course. Mr. Nugent thought it
the most charming thing in the world that I should want “more
exercise” after the heavy tramp of the morning. He said one rather
clever thing, by the way. The others, after a time, wandered down to
the foot of the palisade in search of the ice caves, and as I rather
feared that Mr. N., under the influence of the wild beauty about us,
might lose a self-control which is plainly manufactured and
maintained through a fear of losing everything, (I dread and almost
long for the time when it will give way altogether) I turned the
conversation to politics and asked him if he looked forward to the
possible Bryan administration with the great apprehension that other
Republicans seemed to feel.
“No; I can’t say I do,” he said. “Nothing is ever as bad in politics as
the anticipations; anticipations are the exaggerations of much talk.
Besides—it is quite on the cards that Bryan will be an arrant snob
before he has been a month in the White House. Likely as not, his
first taste of Society will induce conservatism. When he has sat at
table a few times with titled Ambassadors he will hasten to forget the
ridiculous little farm he bought to have his pictures taken in. Then,
the only thing left for us to do is to marry his daughter to a gentleman
and persuade him to send his son to Harvard. His reform will be
accomplished in less than a year. There is no snob so complete as a
democrat reformed by the right sort of visiting cards. Of course a
small nucleus, the old set of Washington, will not go near the White
House, and as soon as the Bryans discover that diplomats, senators,
cabinet officers and army people are not all the cream of high society
they will become downright aristocrats; and when the shirt-sleeved
voter from Lincoln, Nebraska, calls, will conceal their ennui and
irritation indifferently well. That means alienation of the sons of the
soil, and no second term for Bryan. If Washington is wise it will do its
best to make a fool of him.”
“You haven’t much faith in Mr. Bryan’s much vaunted sincerity,” I said
with a laugh.
“I haven’t a particle,” he said contemptuously. “He has his picture
taken too often.”
The others returned at this juncture and we set out upon the
difficulties of our homeward journey. But never mind, it was all very
delightful and I never shall forget the beauty of that rocky glade.
When we returned to the camp, we found Mrs. Meredith Jones
asleep and Miss Page keeping watch. The men had all gone fishing
and Mr. Nugent and Mr. Latimer hastened to join them. Miss Page
looked refreshed but turned to me a perturbed face.
“I cannot believe it is possible that we are all going to sleep in there,”
she said. “Why, it is shocking! I begged Mr. Van Worden to put up a
partition, but he says it is quite impossible, that there won’t be room
to turn over, as it is. I wish I hadn’t come. Suppose it should get out?
Why, people would be horrified.”
“Really,” I said, “I think you take an exaggerated view. We are all
going to bed with our clothes on, the camp is open, there are nine of
us, and our chaperons will sleep in the middle. We may not be
comfortable but I think the proprieties will take care of themselves.”
“I think it is shocking,” she said, “perfectly shocking. It seems so
coarse and horrid. I’ll remember it as long as I live.”
I felt like shaking her, but she looked so distressed that I said
soothingly: “Please don’t worry. I will sleep next to Mrs. Meredith
Jones and you can tuck away in the corner where no one can see
you and you will be quite forgotten.”
“Yes,” she replied quickly, “I insist upon having the corner—
particularly as you don’t mind,” she added apologetically. “You are
quite different from my idea of English girls. I should have thought
that you would be simply horrified.”
“Perhaps we are more matter-of-fact than you are,” I said drily.
“Where a thing can’t be helped it can’t, and we are sensible about it.
Now, I am surprised at you. I had always supposed that American
girls——”
“Oh, don’t!” she exclaimed. “You are going to judge us all by those
horrid things you meet in Europe and in novels. I can assure you that
Southern girls—gentlewomen—are as particular as English girls—
more so, I reckon. Do you realise that we are going to sleep in the
same room with six men?”
“I don’t look at it in that way at all,” I said tartly. “And for heaven’s
sake make up your mind to the inevitable and think no more about
it.”
The men returned soon after with a basket full of trout and Mr. Van
Worden fried them for supper. I don’t think I ever eat anything quite
so good as those trout.
“He beats the cars, cookin’,” observed our chief guide, and Mr. Van
Worden looked as pleased as if he had made a million in Wall Street.
After supper the guides built a high fire of great logs, and we all sat
about and the men “spun yarns” of the days when the panther and
the bear roamed the woods, and finished with stories of the beautiful
red deer that alone claims the forest to-day. Of course the men
smoked, and we were all very happy and comfortable until we went
to bed. Mr. N. sat as close to me as he decently could, and—I will
confess to you, Polly—under the encouragement of the shadows
which covered a part of me and all of him he held my hand. I could
not struggle—well——
About ten the men all marched up the hill in single file, singing, and
we had the camp to ourselves for a half hour. We took off our boots,
corsets and blouses, put on dressing sacks, tied our heads up in silk
handkerchiefs, and our night toilet was complete. Miss Page had
evidently made up her mind to accept the situation, but she was so
manifestly uncomfortable that I tied nearly all of her face up in her
handkerchief and tucked her away in the corner with the blanket up
to her nose. She turned her back upon us and regarded the chinks of
the bark wall in silent misery. Mr. Van Worden had brought three
extra pairs of socks and these he had directed us to pull over our
stockings as the night would grow very cold.
We had been in bed nearly twenty minutes and had already learned
something of its hardness when the men returned.
“Now,” said Opp, “you must all lie on the same side and when one of
you wants to turn over be sure to sing out and then we’ll all turn over
together.”
His was the only remark. The other men pulled off their boots and
crawled into bed without a word, looking rather sheepish, and
ostentatiously refraining from glancing in our direction. Men are
certainly more modest than women in certain conditions, and Mrs.
Meredith Jones and I almost laughed out loud, especially as the
other guide went to bed with his hat on!
For about a half hour we were as quiet as the sardines we must
have looked. Then my side—the one I was lying on—began to ache
from my neck to my heel, and from the numerous sighs and restless
jerks I inferred that we all were affected in the same way. At all
events Opp “sang out,” “Heave over, hey?” and we all turned like a
well-regulated machine. I whispered to Miss Page but she would not
answer me.
It was just after that we became conscious that the temperature was
about ninety. The fire was not three feet in front of us and blazing
more violently every moment. I had been endeavouring to forget my
discomfort in watching the black masses of the tree-tops thrown by
the blaze into extraordinary relief against the dulled sky and
tarnished stars, when I heard Mr. Van Worden whisper fiercely,
“What in heaven’s name did you build that red hot fire for? It’s hot
enough for three camps and we won’t sleep a wink.”
Opp replied apologetically: “I thought it was goin’ to rain and it was
best to have things well het up, but I guess it haint. It’s hot and no
mistake.”
I saw Mr. Latimer fighting to get out of an extra sweater without
attracting attention, and I, by the same herculean efforts, managed
to reach down and get off my stockings and those socks. But still the
heat was insupportable and the bed grew harder every moment. Our
pillows, too, were logs under the spruce, and I am used to a baby
pillow that I double under my neck and face. How I longed for it!
Finally Latimer slipped out of bed and went over to the edge of the
clearing and lit his pipe. The guides followed immediately, then Mr.
Meredith Jones, and they sat along the log in dejected silence. Mrs.
Meredith Jones heaved a deep sigh. “I really can’t stand it, girls,” she
whispered; and followed her husband. Of course we went too, and
Mr. Van Worden was left alone.
For a half hour we sat about in an almost complete silence, waiting
for that wretched fire to burn down. Opp separated the logs, and
finally, as we were all too sleepy to hold our heads up, we crawled
back to bed, one by one, all except Mr. Latimer, who stretched out on
the table, and Mr. Nugent who made a bed for himself on the ground.
That gave us a trifle more room in the camp, and we could turn
without “singing out.” In a few minutes, hot as it still was, I fell asleep.
I suppose it was two hours later that I awoke. The fire had taken a
fresh start and was blazing more merrily than ever. I felt as if I were
in a Turkish bath, and as Miss Page was no longer in front of me I
inferred that she had been driven forth again. Then it occurred to me
that she would not have budged without Mrs. Meredith Jones, and I
turned about quite suddenly. Mrs. M. J. was not there! Nor Mr. M. J.
Nor the guides. Oh, Agatha! Agatha! I was alone in bed with Mr. Van
Worden.
The situation was humorous, but somewhat embarrassing. I hardly
knew whether to pretend sleep or not, for I did not feel like going out
and sitting on that log again. I could see the dark figures in various
dejected attitudes. Mrs. M. J. and Miss Page were sitting back to
back with their heads hanging, while Mr. M. J. stood with his hands
in his pockets glowering at the fire. Latimer was sitting on the table
smoking his pipe, and Mr. N. was digging his heels viciously into the
earth. As for the guides they lay flat in the distance, tired out, poor
things. Only Mr. Van Worden looked serene. He, too, lay on his back,
his hands clasped over the greater part of him. I supposed he was
asleep, but he remarked genially:
“Hot, isn’t it, Lady Helen? I’m afraid one camping experience will do
you for the rest of your natural life.”
I assured him that I never had been so much entertained, and we
conversed as naturally as if it had been noon-day until I was
reminded of the irregularities of the situation by a gasp from Miss
Page. She nudged Mrs. M. J., whispered hurriedly, and in another
moment I was chaperoned on either side.
It was at least another hour before the fire burned down and the
temperature cooled. Then the men crawled back to bed, one by one,
and in a few moments they were all sleeping—and as quietly as
kittens. It really was quite remarkable.
But one could not sleep long at a time on that bed, and once I was
glad to be awake. High up on the highest tree of the mountain a hoot
owl broke the petrified stillness of that lonely forest.
“Too wit, too wit, too wooo!” he called loudly, and then he added with
impatient emphasis, “Too wit, too wit, too woo,” as if to say, “Do you
understand that?” He was a bit of a scold, but he had all the grey
dome and all the forest depths to talk into. No comrade answered
him, and nothing ever gave me such an impression of the solitude of
a mountain forest.
By six o’clock we had endured all that the human frame is capable of
in the way of sleeping on hard and prickly spruce, and the men rose
as by one impulse and went down to the spring to wash. We dressed
as hurriedly as possible, and, I must say, looked surprisingly fresh.
And the morning was so deliciously cool, and Mr. Van Worden’s
coffee so fragrant and bracing, his trout so crisp and Mrs. Opp’s
“johnnie cake,” so excellent that we sat about Mr. Latimer’s bed in
the highest spirits and congratulated each other that we were
“camping out.” Even Miss Page, having weathered the worst of it,
announced herself ready to stay another night, and talked continually
in her pretty Southern brogue. She was looking like a beautiful
gypsy, too, and I think our one small mirror had consoled her for
many things. She flashed her eyes about with the impartiality of the
kind-hearted coquette, and was quite the life of the uncomfortable
group about the table.
After breakfast Mrs. M. J., Latimer, Mr. Nugent and myself, led by
Opp, with an axe over his shoulder, started off to see some famous
falls. The rest went fishing. As the trail along the “still-water” had
been choked by lumbermen, Opp had to rely on his general
knowledge of the land, and every few minutes he “blazed” a tree,
i.e., hacked off a piece of the bark with his axe, that there should be
no danger of going astray when we returned. The ground was less
broken up than usual and we strode along in single file looking for all
the world like a party of pioneers penetrating the wilderness. It was a
jolly experience and I would not have missed it for anything.
The falls were about two miles from the camp and we were an hour
reaching them, for Opp got off the track several times. I can imagine
that they look very fine indeed when there is anything falling. But all
we saw was a sloping wall of solid rock, about four hundred and fifty
feet high and a fifth of a mile wide, crowned with spruce. There is a
deep wide pool below, and a mass of rocks on which we sat and
tried to picture the mighty cascade of other seasons. On one end—
the perpendicular end—of the wall there were soil and trees, and
Opp asked me if I would like to “climb the falls and see the sights.” I
was half way across the rocks in a moment with Mr. N. and Latimer
after me, while Opp remained with Mrs. M. J.
It was a straight climb, my dear, of four hundred and fifty feet. It
hardly sloped once and there was just one ledge of about six steps.
We had to pull ourselves up by trees and bushes, and more that
once Mr. N. dragged me up, while Mr. L. pushed me. But altogether I
did rather well, and was quite rewarded by their enthusiastic
approval. But there was a better reward than that. From an elevation
above the falls we saw five mountain ranges. They seemed to fill all
space, and the blue dome to press down its rim about them, holding
such a flood of crystal and gold! There were many beautiful pines
about us, sage green with a delicate fairy-like quality in spite of their
greatness, and once more the undesecrated forest, so dense that
Mr. N. had noted every inch of ground we traversed.
Of course it was worse going down than ascending and I was glad to
have two men to take care of me.
Well, we spent all of that day very pleasantly, and the night promised
to be rather more comfortable, for Mr. Nugent, Mr. Latimer, and the
guides all made beds for themselves under the stars and the fire was
left to go out after supper. But, alas! about midnight it began to rain,
they all came crawling under shelter, and there was little more sleep
that night.
The rain stopped long enough for us to breakfast comfortably, and
then we held a consultation. The plan had been to “stay out” three
nights, but we were all a little tired of it, and the skies looked very
forbidding.
“If you want my opinion,” remarked Opp, “I say go, and be quick
about it. It’s set in for all day, and if we git back to the Lake without a
soakin’ we’ll be luckier’n I think we will.”
That settled it. We had no desire to sit on our bed all day and then
sleep on it another night. The guides began to pack at once, and
within an hour we were on our way.
We had hardly started when it began to pour, and it has not stopped
yet. What a walk it was! However we reached home without
pneumonia and broken ankles heaven only knows, but not one of us
has a cold; and although my feet feel as if they had been pounded
with a hammer they are quite whole. When we were not picking our
way over the narrow trail through the brush—dripping and as high as
our heads—we were on those horrible corduroy roads, made so
slippery by the rain that every step was a danger. Once I fell, and I
twisted my foot three times and wrenched myself up to my waist. My
feet were swimming in my boots and it was an effort to lift them. I felt
sorry for Miss Page, who is a pampered creature, but she never
uttered a complaint, although she told me afterward that every time
we came to one of those interminable stretches of corduroy she
wanted to sit down and cry. She certainly is a fine creature, with all
her little foibles.
When we got to the lumber camp we all sat down in the rain and
rested before climbing the corduroy hill beyond. Mr. N. explained to
me the use of the curious objects piled under a shed. They were
huge boxes on runners with four round holes in each end. When the
snow is on the ground, covering corduroy and rocks, these boxes
are filled with water and dragged by horses over the road to be used
for drawing the lumber to the streams. From the front holes the water
spouts continuously, and as it strikes the ground it freezes, making a
solid smooth surface over which the log sledges can travel with
ease. But what a life! No wonder these mountaineers look old; but
Mr. N. told me that lumbermen become so fascinated with the life
that they cannot be tempted into the valleys.
You can imagine the difficulties of that narrow sidling swampy trail by
the inlet. It was just twice as bad as in dry weather, and I almost was
discouraged once or twice. Perhaps I should have been, had it not
been for a very reassuring and helpful presence; but it was bad
enough.
Latimer had hastened on to the lake to fire his revolver, the signal
that we were coming. When the rest of us arrived the boats were
almost there, but as we were all hot and wet, and a cold wind played
upon us as we stood on the stones again, it is a wonder we are not
all wrecks. As soon as I reached home Mrs. Van Worden made me
drink hot whiskey, while Mrs. Opp and Henriette undressed and
rubbed me down. I am none the worse for wear, but felt quite done
up by half-after seven and went to bed. Hence this great letter. Good
night. I return to Boulder Lake to-morrow.
Helen.
Boulder Lake
August 20th
10 p. m.
I forgot to give this letter to the postman to-night so I will tell you of
two or three surprises which have made me wide-awake, rather.
Of course Mr. Nugent returned with me, (and as there is always a
room at the Club House at his disposal I suppose he will remain
through the deer and grouse seasons—unless—but I vow I don’t
know!) I was glad to see that beautiful avenue dividing the dark
forest, once more, and we walked slowly, the buckboard following. I
can’t say the familiar corduroy filled me with sentimental emotions
and my insteps ached at the first glimpse of it; but I have that
buoyancy within that carries my feet over many a weary mile, and
my companion, as ever, was very interesting. I forget just what we
talked about.
We were half way up the last hard bit of corduroy and my eyes as
usual were intent upon the logs when Mr. N. said abruptly:
“Look!”
I stopped at once and followed the direction of his glance. Before I
had time to wonder if he had seen a bear I saw, standing on the
ledge above, Mr. Rogers—and Bertie! The light was full upon them
and I saw in a flash that Bertie was stouter and had lost his terrible
pallor. He was not ruddy, but he was brown, and there was colour in
his cheeks.
Polly, did you ever have a wild whirl of emotions inside of you while
you forced your exterior to be as impassive as a shell? I wanted to
give one of the war-whoops with which they call to one another up
here, and I felt so much like bursting into a storm of tears that I dared
not even speak.
When Bertie and I met we merely shook hands, and he remarked
that he was glad to see me back, but I knew he wanted to hug me.
Then I gave my hand to Mr. Rogers—and was just in time to see the
look with which my two knights were measuring each other.
I walked ahead with Bertie and he said that between the air and the
milk he certainly was getting well, and I found my voice and told him
that I never had felt so happy in my life. But my absorption in Bertie
was divided for the moment by a new surprise.
We had left the level stretch and were walking down the incline to
the boat landing (I had been too interested to notice that we had not
turned off into the path leading to our camp), when I stopped short
with half a sentence forgotten. Waiting at the pier was a gondola—a
gondola with silken curtains and cushions and an Italian gondolier.
Bertie laughed gaily at my startled face, for in truth I was afraid for
the moment that something in my brain had gone wrong.
“Rogers sent for it—to Chicago, of all places!” he said. “It is a
remnant of the World’s Fair.”
And then I remembered I once had said to Mr. Rogers that I could
not understand why they did not have gondolas on these beautiful
lakes instead of commonplace boats.
All my coquetry was enchanted and I turned to Mr. Rogers with such
a radiant face that he must have felt a bit rewarded. While I was
thanking him—glad of that much outlet for my excitement—and he
was making one of his charming speeches and looking so dignified
and not the least bit of an ass, I stole a glance at Mr. N. His face
wore a cynical grin that was almost sardonic.
Well, I gondolaed home and fell into Agatha’s arms, then discovered
Bertie’s welcome. He had—himself, mind you—tacked that most
beautiful of shrubs, the ground pine, all over the walls of the living-
room. They looked a mass of soft green and gold and the antlered
heads of the deer seemed to be set in their native woods. On the
table was a great bunch of crimson sweet peas—incomparably more
fragrant than ours—sent by Jemima, and a bowl of water-lilies from
Mrs. Laurence.
After I had answered all of Agatha’s questions and assured her that I
was as well as ever—she thinks I am thin, but how I have tramped!
—Bertie and I went out and gondolaed round the lake. It was just five
o’clock. The men were going home from the tennis court, and waved
their hats at me and gave the unearthly wood call.
Then, suddenly, all the doors opened, and the women in their bright
muslin gowns flitted out and waved their handkerchiefs to me. It was
a pretty sight and a graceful act. Of course, I landed and they said a
great many of their charming things.
When I went home another surprise awaited me—in my room. On
the table was a box of splendid roses and an elaborate basket of
chocolates tied with yards of my favourite bright blue ribbon. Mr.
Nugent’s card was attached. Of course he had sent to New York for
them.
I don’t think I ever went to bed feeling so happy.
Helen.
21st
I suppose we have all taken note of that malignant influence in the
unseen world which makes us unreasoningly and unguardedly
happy just before our stiffest blows. One would think these bitter
contrasts were purposely arranged to destroy our power of
philosophy.
It was at breakfast that I was confounded, more nearly knocked over
than I ever was in my life.
“By the way, Nell,” Bertie remarked casually, “what a ripping fine
woman Mrs. Coward is.”
“Mrs. Coward?” I gasped.
“Yes. Don’t mean to say you didn’t know she was here?”
“I did not!” I could barely articulate. And a perturbed glance from
Agatha increased my consternation. “When did she come?”
“Three or four days ago—Oh, yes, she said you had left the same
morning for your camping tramp.”
“Whom is she visiting? I had no idea the aristocracies would mix.”
“Mrs. Laurence. Don’t you like Mrs. Coward?”
“I am glad she is visiting Mrs. Laurence. I should say they would
scratch each other’s eyes out immediately.”
“I’m disappointed you don’t like her. I hoped you’d have her in the
house a lot. She’s a long sight the most fascinating American I ever
met—a regular ripper, by gad!”
I don’t know how I controlled myself, but I knew that if I said too
much and suggested opposition Bertie would be on his hind legs at
once.
This was what she had up her sleeve, Polly. What deceit, what
treachery, what sneakingness. Only a widow would be capable of
such a thing. But I must say I respect her. She fooled me completely.
I could not have been capable of so clever a revenge, and I detest
her for it, because she has not the true sporting instinct, but she is to
be reckoned with all the same. In spite of her platitudes and her
ingenuous pride in the seven generations, she is both clever and
deep—when her pride is in arms, and revenge and ambition both
spur her on to capture a duke.
But will she marry him? Oh! Many moths have fluttered about that
flame. But she is so subtle. And in addition to her indisputable
magnetism she has developed fascination into a fine art. Of course
she has scented out all Bertie’s weak points and flattered them. I can
hear her discoursing about the solemn responsibilities of the
hereditary legislator, and that is what is haunting Bertie most at
present. Of course she knows all about Dad, and her dulcet
enthusiasms on that convenient weakness—Oh, dear! Agatha says
they have been almost inseparable since the afternoon she arrived.
She did not lose a minute!
He actually asked me if he could take her out in my gondola. I felt
like telling him to take her out and drown her, but I gave my consent
as graciously as I could, and came into the house to think. I dare not
go to the forest, for I know that Mr. N. is lying in wait for me and I feel
certain that after this gondola declaration he will press his suit; and
when he does plant himself on both feet in the middle of the trail and
I on the wrong side—Oh, heaven!
I induced Agatha to go over to the tennis court so that I could not
receive Mr. Rogers if he called. But for some time I could not even
write to you, I could only storm up and down the living-room and try
to think of some way to foil that woman and deliver Bertie. Fancy
having her for a sister-in-law! And she would radiate a subtle triumph
till the day of her death. But the real—underlying—point is that she is
not the wife for Bertie. He must marry an intelligent woman who will
give herself to him and his career, and this one would be entirely
wrapped in her own petty ambitions.
It suddenly occurred to me that Miss Page had promised to spend
the first two weeks of September with me. She is still at Chipmunk
Lake, for the other women do not leave for two days yet. The
buckboard had not gone. I wrote her a note, imploring her to come at
once as I was bored and lonely. Then I bribed the driver to take it to
her to-day, and he said he would wait and bring her back. She is far
more beautiful than Mrs. C., and younger. She may not be so subtle
but she has all the fascination of a buoyant and unaffected coquette.
And she is worth six of Mrs. C. as regards character and sincerity.
Not, alas! that that adds to one’s power over man. But I am hoping
that Bertie will contrast her real brightness with Mrs. C.’s platitudes,
and discover that the widow is boring, that he will succumb to Miss
Page’s superior beauty, and that propinquity will do its work. If only it
doesn’t all happen before she gets here! Mrs. C. has had him in her
pocket for three hours—in my gondola. She has on a white frock and
a scarlet shawl and a red poppy in her hair. There is no denying that
she is hideously attractive. Oh, Polly, how I wish you were here!
To add to my burdens Bertie gave me, this morning—he mercifully
forgot it last night—an impassioned epistle from Mr. Carlisle. His
mother is better and he is returning to Chipmunk Lake for the hunting
season. He says he shall devote three days a week to deer and the
rest to me—that if they won’t invite him to the Club House he’ll camp
on the next lake, which is only a mile away and on State lands. But
of course they’ll invite him to the Club House. Oh, Polly! Do you think
any woman ever was in such a tangle before!
On the whole I think I’ll go out into the forest and talk to Mr. N. about
it. I must talk to somebody or I’ll have brain fever. And I’m used to
diverting his mind—“standing him off,” as they say here. And I want
sympathy.
This is really good-bye. I won’t write another line till I am in a more
cheerful state of mind—induced by Miss Page’s triumph over the
widow—for I do not want to add to your worries.
Helen.
P. S.—Roddy Spencer will arrive on one of the Saturday steamers.
Note.—The correspondence ends abruptly with the above
letter; Lady Helen Pole, on the following day having
received a cablegram announcing the sudden death of the
Earl of Edge and Ross and the immediate departure of her
friend for the United States.
The Publisher.

THE END.
FOOTNOTE:
[A] Deletions by the publisher.
TRANSCRIBER’S NOTES:
Obvious typographical errors have been corrected.
Inconsistencies in hyphenation have been
standardized.
Archaic or variant spelling has been retained.
New original cover art included with this eBook is
granted to the public domain.
*** END OF THE PROJECT GUTENBERG EBOOK THE
ARISTOCRATS ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE

You might also like