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

Download Complete Beginning Python Using Python 2 6 and Python 3 1 Wrox Programmer to Programmer James Payne PDF for All Chapters

Python

Uploaded by

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

Download Complete Beginning Python Using Python 2 6 and Python 3 1 Wrox Programmer to Programmer James Payne PDF for All Chapters

Python

Uploaded by

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

Download Full ebookname - Read Now at ebookname.

com

Beginning Python Using Python 2 6 and Python 3 1


Wrox Programmer to Programmer James Payne

https://ebookname.com/product/beginning-python-using-
python-2-6-and-python-3-1-wrox-programmer-to-programmer-
james-payne/

OR CLICK BUTTON

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Ivor Horton s Beginning Visual C 2010 Wrox Programmer to


Programmer 1st Edition Ivor Horton

https://ebookname.com/product/ivor-horton-s-beginning-
visual-c-2010-wrox-programmer-to-programmer-1st-edition-ivor-horton/

ebookname.com

Programming in Python 3 A Complete Introduction to the


Python Language 2nd Edition Summerfield

https://ebookname.com/product/programming-in-python-3-a-complete-
introduction-to-the-python-language-2nd-edition-summerfield/

ebookname.com

Professional Office Business Application Development Using


Microsoft Office SharePoint Server 2007 and VSTO Wrox
Programmer to Programmer 1st Edition Steve Fox
https://ebookname.com/product/professional-office-business-
application-development-using-microsoft-office-sharepoint-
server-2007-and-vsto-wrox-programmer-to-programmer-1st-edition-steve-
fox/
ebookname.com

Onboarding How to Get Your New Employees Up to Speed in


Half the Time 1st Edition George B. Bradt

https://ebookname.com/product/onboarding-how-to-get-your-new-
employees-up-to-speed-in-half-the-time-1st-edition-george-b-bradt/

ebookname.com
McDougal Littell Literature Grade 8 Janet Allen

https://ebookname.com/product/mcdougal-littell-literature-
grade-8-janet-allen/

ebookname.com

The Chief Learning Officer Driving Value Within a Changing


Organization Through Learning and Development Improving
Human Performance 1st Edition Tamar Elkeles
https://ebookname.com/product/the-chief-learning-officer-driving-
value-within-a-changing-organization-through-learning-and-development-
improving-human-performance-1st-edition-tamar-elkeles/
ebookname.com

Social work practice with transgender and gender variant


youth 2nd Edition Gerald P. Mallon

https://ebookname.com/product/social-work-practice-with-transgender-
and-gender-variant-youth-2nd-edition-gerald-p-mallon/

ebookname.com

Music Therapy Improvisation for Groups Essential


Leadership Competencies 1st Edition Susan Gardstrom

https://ebookname.com/product/music-therapy-improvisation-for-groups-
essential-leadership-competencies-1st-edition-susan-gardstrom/

ebookname.com

Modern Residential Construction Practices 1st Edition


David A. Madsen

https://ebookname.com/product/modern-residential-construction-
practices-1st-edition-david-a-madsen/

ebookname.com
Oilseed crops Yield and Adaptations under Environmental
Stress 1st Edition Parvaiz Ahmad

https://ebookname.com/product/oilseed-crops-yield-and-adaptations-
under-environmental-stress-1st-edition-parvaiz-ahmad/

ebookname.com
Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™

Beginning

Python
Using Python 2.6 and Python 3.1
®

James Payne
Programmer to Programmer™

Get more out of


wrox.com
Interact Join the Community
Take an active role online by participating in our Sign up for our free monthly newsletter at
P2P forums @ p2p.wrox.com newsletter.wrox.com

Wrox Online Library Browse


Hundreds of our books are available online Ready for more Wrox? We have books and
through Books24x7.com e-books available on .NET, SQL Server, Java,
XML, Visual Basic, C#/ C++, and much more!
Wrox Blox
Download short informational pieces and code
to keep you up to date and out of trouble!

Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing wrox-partnerwithus@wrox.com
Beginning Python®: Using Python 2.6 and Python 3.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvii

Part I: Dipping Your Toe into Python


Chapter 1: Programming Basics and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2: Numbers and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Chapter 3: Variables — Names for Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Part II: Python Language and the Standard Library


Chapter 4: Making Decisions ....................................................................... 51
Chapter 5: Functions ................................................................................... 71
Chapter 6: Classes and Objects ................................................................... 93
Chapter 7: Organizing Programs ................................................................. 111
Chapter 8: Files and Directories ................................................................. 127
Chapter 9: Other Features of the Language ................................................ 143
Chapter 10: Building a Module ................................................................... 157
Chapter 11: Text Processing ...................................................................... 189

Part III: Putting Python to Work


Chapter 12: Testing ................................................................................... 207
Chapter 13: Writing a GUI with Python ....................................................... 227
Chapter 14: Accessing Databases.............................................................. 239
Chapter 15: Using Python for XML ............................................................. 265
Chapter 16: Network Programming ............................................................ 287

Continues
Chapter 17: Extension Programming with C................................................ 337
Chapter 18: Numerical Programming .......................................................... 367
Chapter 19: An Introduction to Django ....................................................... 387
Chapter 20: Web Applications and Web Services ........................................ 407
Chapter 21: Integrating Java with Python ................................................... 481

Part IV: Appendices


Appendix A: Answers to the Exercises........................................................ 515
Appendix B: Online Resources.................................................................... 549
Appendix C: What’s New in Python 3.1 ....................................................... 553
Appendix D: Glossary................................................................................. 559

Index ........................................................................................................ 569


Beginning
Python®
Beginning
Python®
Using Python 2.6 and Python 3.1

James Payne

Wiley Publishing, Inc.


Beginning Python®: Using Python 2.6 and Python 3.1
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-41463-7
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties
with respect to the accuracy or completeness of the contents of this work and specifically disclaim all
warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be
created or extended by sales or promotional materials. The advice and strategies contained herein may not
be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in
rendering legal, accounting, or other professional services. If professional assistance is required, the services of a
competent professional person should be sought. Neither the publisher nor the author shall be liable for
damages arising here from. The fact that an organization or Web site is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses the
information the organization or Web site may provide or recommendations it may make. Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared between when
this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department
within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
Library of Congress Control Number: 2009936814
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade
dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United
States and other countries, and may not be used without written permission. Python is a registered trademark
of Python Software Foundation. All other trademarks are the property of their respective owners. Wiley
Publishing, Inc. is not associated with any product or vendor mentioned in this book.
To my patient and loving wife, Whitney, who believed in me before I did. And to my parents,
Ronnie and Sharon Payne, who raised me to believe I could do anything I put my mind to, even
when I told them I wanted to be Santa Claus. For my brother, Ron, who read my work even when
it was bad, Dorjan, Eric, Clem, and Nick because they know things about me and
will tell them if I don’t include them.
About the Author
James Payne (Margate, FL) is Editor-in-Chief of Developer Shed, Inc. and has been writing and
programming since the age of seven years old. Proficient in many languages, he has written over
400 articles covering practically every major programming language. As a contractor, he develops
proprietary software for the financial industry using Python and likes to dabble in Django in his
spare time.
Credits
Executive Editor Production Manager
Carol Long Tim Tate

Project Editor Vice President and Executive Group Publisher


Ed Connor Richard Swadley

Technical Editor Vice President and Executive Publisher


Chris McAvoy Barry Pruett

Production Editors Associate Publisher


Amy Weintraub and Tim Tate Jim Minatel

Copy Editor Project Coordinator, Cover


Kim Cofer Lynsey Stanford

Editorial Director Proofreaders


Robyn B. Siesky Scott Klemp and Kristy Eldredge, Word One

Editorial Manager Indexer


Mary Beth Wakefield Ron Strauss

Marketing Manager Cover Image


David Mayhew © istockphoto.com/Frank_U
Acknowledgments

I would like to acknowledge the gang at Developer Shed: Jack and Jay Kim, whose constant hatred is an
inspiration, Charles Fagundes, who made me an editor and not just a writer, Keith Lee, who provided
coding support, and a special thanks to Jenny Ruggieri, who got me the job that got me this book. Lastly,
I’d like to thank all of the people that worked on the previous editions of this book for laying the
groundwork, and the Editors Carol Long, Jenny Watson, Ed Connor, and Chris McAvoy who helped me
meet deadlines no matter how much I didn’t want to.

I would also like to acknowledge Guido Von Rossum, without whom there would be no language to
write about.
Contents

Introduction xxvii

Part I: Dipping Your Toe into Python 1


Chapter 1: Programming Basics and Strings 3
How Programming is Different from Using a Computer 3
Programming is Consistency 4
Programming is Control 4
Programming Copes with Change 5
What All That Means Together 5
The First Steps 5
Installing Python 3.1 on Non-Windows Systems 6
Using the Python Shell 6
Beginning to Use Python — Strings 7
What is a String? 7
Why the Quotes? 7
Why Three Types of Quotes? 8
Using the print() Function 8
Understanding Different Quotes 9
Putting Two Strings Together 11
Joining Strings with the Print() Function 12
Putting Strings Together in Different Ways 12
Summary 13
Exercises 14

Chapter 2: Numbers and Operators 15


Different Kinds of Numbers 15
Numbers in Python 16
Program Files 18
Using the Different Types 19
Basic Math 21
Some Surprises 23
Using Numbers 24
Order of Evaluation 24
Number Formats 25
Contents
Mistakes Will Happen 26
Some Unusual Cases 27
Summary 28
Exercises 29

Chapter 3: Variables — Names for Values 31


Referring to Data — Using Names for Data 31
Changing Data Through Names 33
Copying Data 33
Names You Can’t Use and Some Rules 34
Using More Built-in Types 34
Tuples — Unchanging Sequences of Data 34
Lists — Changeable Sequences of Data 37
Dictionaries — Groupings of Data Indexed by Name 39
Treating a String Like a List 41
Special Types 42
Other Common Sequence Properties 43
Referencing the Last Elements 43
Ranges of Sequences 44
Growing Lists by Appending Sequences 45
Using Lists to Temporarily Store Data 45
Working with Sets 46
Summary 47
Exercises 48

Part II: Python Language and the Standard Library 49


Chapter 4: Making Decisions 51
Comparing Values — Are They the Same? 51
Doing the Opposite — Not Equal 53
Comparing Values — Which One Is More? 54
More Than or Equal, Less Than or Equal 55
Reversing True and False 56
Looking for the Results of More Than One Comparison 56
How to Get Decisions Made 57
Repetition 60
How to Do Something — Again and Again 60
Stopping the Repetition 62
Handling Errors 65
Trying Things Out 65

xvi
Contents
Summary 67
Exercises 69

Chapter 5: Functions 71
Putting Your Program into Its Own File 71
Functions: Grouping Code under a Name 73
Choosing a Name 75
Describing a Function in the Function 75
The Same Name in Two Different Places 76
Making Notes to Yourself 78
Asking a Function to Use a Value You Provide 79
Checking Your Parameters 81
Setting a Default Value for a Parameter—Just in Case 83
Calling Functions from within Other Functions 84
Functions Inside of Functions 86
Flagging an Error on Your Own Terms 87
Layers of Functions 88
How to Read Deeper Errors 88
Summary 89
Exercises 90

Chapter 6: Classes and Objects 93


Thinking About Programming 93
What is an Object? 93
Objects You Already Know 94
Looking Ahead: How You Want to Use Objects 95
Defining a Class 96
How Code Can Be Made into an Object 96
Objects and Their Scope 104
Summary 107
Exercises 108

Chapter 7: Organizing Programs 111


Modules 112
Importing a Module So That You Can Use It 112
Making a Module from Pre-existing Code 113
Using Modules — Starting with the Command Line 115
Changing How Import Works — Bringing in More 118
Packages 118

xvii
Contents
Modules and Packages 120
Bringing Everything into the Current Scope 120
Re-importing Modules and Packages 121
Basics of Testing Your Modules and Packages 124
Summary 124
Exercises 125

Chapter 8: Files and Directories 127


File Objects 127
Writing Text Files 128
Appending Text to a File 129
Reading Text Files 130
File Exceptions 131
Paths and Directories 131
Exceptions in os 132
Paths 132
Directory Contents 135
Obtaining Information about Files 136
Renaming, Moving, Copying, and Removing Files 137
Example: Rotating Files 138
Creating and Removing Directories 140
Globbing 140
Summary 142
Exercises 142

Chapter 9: Other Features of the Language 143


Lambda and Filter: Short Anonymous Functions 143
Map: Short-Circuiting Loops 144
Decisions within Lists — List Comprehension 145
Generating Iterators for Loops 146
Special String Substitution Using Dictionaries 148
Featured Modules 149
Getopt — Getting Options from the Command Line 149
Using More Than One Process 152
Threads — Doing Many Things in the Same Process 154
Summary 156
Exercises 156

xviii
Contents

Chapter 10: Building a Module 157


Exploring Modules 157
Importing Modules 159
Finding Modules 159
Digging through Modules 160
Creating Modules and Packages 162
Working with Classes 163
Defining Object-Oriented Programming 163
Creating Classes 163
Extending Existing Classes 165
Finishing Your Modules 166
Defining Module-Specific Errors 166
Choosing What to Export 167
Documenting Your Modules 168
Testing Your Module 176
Running a Module as a Program 178
Creating a Whole Module 179
Installing Your Modules 183
Summary 187
Exercises 188

Chapter 11: Text Processing 189


Why Text Processing Is So Useful 189
Searching for Files 190
Clipping Logs 191
Sifting through Mail 192
Navigating the File System with the os Module 192
Working with Regular Expressions and the re Module 199
Summary 203
Exercises 204

Part III: Putting Python to Work 205


Chapter 12: Testing 207
Assertions 208
Test Cases and Test Suites 209
Test Fixtures 213
Putting It All Together with Extreme Programming 216

xix
Contents
Implementing a Search Utility in Python 216
A More Powerful Python Search 222
Formal Testing in the Software Life Cycle 224
Summary 225

Chapter 13: Writing a GUI with Python 227


GUI Programming Toolkits for Python 228
Tkinter Introduction 229
Creating GUI Widgets with Tkinter 229
Resizing the Widget 230
Configuring Widget Options 231
Putting the Widgets to Work 231
Creating Layouts 232
Packing Order 233
Controlling Widget Appearances 233
Radio Buttons and Checkboxes 235
Dialog Boxes 236
Other Widget Types 237
Summary 238
Exercises 238

Chapter 14: Accessing Databases 239


Working with DBM Persistent Dictionaries 240
Choosing a DBM Module 240
Creating Persistent Dictionaries 241
Accessing Persistent Dictionaries 243
Deciding When to Use DBM and When to Use a Relational Database 245
Working with Relational Databases 245
Writing SQL Statements 247
Defining Tables 249
Setting Up a Database 250
Using the Python Database APIs 252
Downloading Modules 252
Creating Connections 253
Working with Cursors 253
Working with Transactions and Committing the Results 260
Examining Module Capabilities and Metadata 261
Handling Errors 261
Summary 262
Exercises 263

xx
Contents

Chapter 15: Using Python for XML 265


What Is XML? 265
A Hierarchical Markup Language 265
A Family of Standards 267
What Is a Schema/DTD? 268
What Are Document Models For? 268
Do You Need One? 268
Document Type Definitions 268
An Example DTD 268
DTDs Aren’t Exactly XML 270
Limitations of DTDs 270
Schemas 270
An Example Schema 270
Schemas Are Pure XML 271
Schemas Are Hierarchical 271
Other Advantages of Schemas 271
XPath 272
HTML as a Subset of XML 272
The HTML DTDs 273
HTMLParser 273
XML Libraries Available for Python 274
What Is SAX? 274
Stream-based 275
Event-driven 275
What Is DOM? 275
In-memory Access 275
Why Use SAX or DOM 275
Capability Trade-Offs 276
Memory Considerations 276
Speed Considerations 276
SAX and DOM Parsers Available for Python 276
xml.sax 276
xml.dom.minidom 277
Intro to XSLT 280
XSLT Is XML 280
Transformation and Formatting Language 280
Functional, Template-Driven 280
What Is lxml? 280
Element Classes 281
Adding Text to Elements 282

xxi
Contents
Parsing with lxml 283
Parsing Files 284
Summary 285
Exercises 285

Chapter 16: Network Programming 287


Understanding Protocols 289
Comparing Protocols and Programming Languages 289
The Internet Protocol Stack 290
A Little Bit About the Internet Protocol 292
Sending Internet E-mail 293
The E-mail File Format 294
MIME Messages 295
Sending Mail with SMTP and smtplib 303
Retrieving Internet E-mail 305
Parsing a Local Mail Spool with mailbox 305
Fetching Mail from a POP3 Server with poplib 307
Fetching Mail from an IMAP Server with imaplib 309
Secure POP3 and IMAP 313
Webmail Applications Are Not E-mail Applications 313
Socket Programming 314
Introduction to Sockets 314
Binding to an External Hostname 316
The Mirror Server 317
The Mirror Client 318
SocketServer 320
Multithreaded Servers 321
The Python Chat Server 322
Design of the Python Chat Server 323
The Python Chat Server Protocol 323
The Python Chat Client 329
Single-Threaded Multitasking with select 331
Other Topics 332
Miscellaneous Considerations for Protocol Design 333
The Peer-to-Peer Architecture 333
Summary 334
Exercises 335

Chapter 17: Extension Programming with C 337


Extension Module Outline 338
Building and Installing Extension Modules 340

xxii
Contents
Passing Parameters from Python to C 342
Returning Values from C to Python 345
The LAME Project 346
The LAME Extension Module 350
Using Python Objects from C Code 363
Summary 366
Exercises 366

Chapter 18: Numerical Programming 367


Numbers in Python 368
Integers 368
Long Integers 369
Floating-point Numbers 369
Formatting Numbers 370
Characters as Numbers 373
Mathematics 374
Arithmetic 374
Built-in Math Functions 375
Complex Numbers 378
Arrays 380
The array Module 382
Summary 384
Exercises 384

Chapter 19: An Introduction to Django 387


What Are Frameworks and Why Would I Use One? 388
Other Features of Web Frameworks 388
Django — How It All Began 389
Installing Django 389
Understanding Django’s Architecture 390
Initial Project Setup 391
Creating a View 394
Working with Templates 396
Using Templates and Views 398
Models 401
Creating a Model: First Steps — Configure the Database Settings 401
Creating a Model: Creating an Application 403
Working with Models: Installation 404
Summary 405
Exercises 406

xxiii
Random documents with unrelated
content Scribd suggests to you:
REMEDIES.
Undoubtedly the most efficient remedy for the bedbug is to
fumigate the infested house or rooms with hydrocyanic-acid gas.
This gas will penetrate into every crevice in the house or room
where the bedbugs conceal themselves and has an immediate
effectiveness which gives it an important recommendation, especially
when the infestation is considerable or of long standing. This
method of fumigation should be intelligently employed, as the gas is
deadly poisonous. A bulletin giving directions for such fumigation has
been issued by the Department of Agriculture.[15]
[15] Howard, L. O., and Popenoe, C. H. Hydrocyanic-acid gas
against household insects. U. S. Dept. Agr. Farmers' Bul. 699. 8 p.
1916.

The fumes of burning sulphur are also a very efficient means of


control where the conditions are such that this method can be used,
readily destroying the insect in all stages, including the egg. The
treatment is inexpensive compared with the use of hydrocyanic-acid
gas and offers much less risk of danger to human beings. There is,
however, a considerable risk of injury to household fabrics,
furnishings, and wall papers from the strong bleaching quality of
sulphur fumes. This danger will be somewhat diminished if the
fumigation can be done at a time when the room or house is
thoroughly dried out, as in winter by a furnace or other heating
system. Further precautions should be taken by removing all metallic
surfaces from the room or building, or by protecting them with a
coating of vaseline. Two pounds of sulphur are recommended for
each 2,000 cubic feet of space, and the building should be closed for
the treatment for at least 5 or 6 hours, or preferably for 24 hours.
Sulphur candles may be used where available, or the sulphurous gas
or fumes can be generated by burning the sulphur in a dish placed
in the center of the room, and for protection set within a larger
vessel. Thorough-going precautions must be taken to prevent
accidental overflowing or the starting of a fire, and after the
fumigation the house should be given a thorough airing.
Other gases have been experimented with, such as formalin and
the vapors of benzine, naphthaline, and camphor, but these gases
are of little value. Similarly, insect powders are of little value, largely
from the difficulty of getting them into the crevices and other places
of concealment of the insects.
Where the use of poisonous gas is difficult or objectionable,
especially if only one room is infested, the pests may be eliminated
by the application of kerosene, benzene, or any of the lighter
petroleum oils, by means of a small hand sprayer. The liquid should
be directed at close range into all cracks and crevices in the walls
and behind loose wall paper. Open spaces back of baseboards and
picture moldings should be liberally treated. The bedstead and
springs should receive the same attention, care being taken to spray
the liquid into all crevices. The mattress should likewise be carefully
gone over. All seams and spaces beneath tuftings should be
thoroughly dosed. At the expiration of 10 days the entire treatment
should be repeated with the same care, regardless of whether any
bugs are seen or not. If the two applications are made with
painstaking care this should be sufficient for complete eradication.
Temperature control.—The possibility of temperature control is
indicated in the discussion elsewhere of the effect of temperature on
this insect. A temperature maintained below freezing for 10 or 15
days destroys the eggs, and this temperature continued for 15 days
to a month will destroy the newly hatched young. It may be,
therefore, that if infested houses in cold climates should be opened
up and allowed to remain at a temperature well below freezing for a
considerable period, all eggs and the young, and possibly most if not
all of the adults, would be exterminated. This method of control
might perhaps be practicable at least in the case of summer houses
in the north which are left untenanted in the winter.
The maintaining of high temperatures may be an even more
efficient method of control. The activity of the bedbug is at its
greatest between 60° and 70° to 75°. As indicated elsewhere, in a
temperature of 96° to 100° F., accompanied with a high degree of
humidity, newly hatched bedbugs perish within a few days, and, if
this temperature is raised to 113° F., in a few minutes. A
temperature of 113° will also destroy the eggs, and with these
higher temperatures the item of humidity is not apparently
important.
A very practical test of this method of control was made in
Ontario, Canada, by the Dominion Entomological Department,[16]
adapting the method of control of insects infesting granaries and
flour mills by superheating. In this instance an eight-room, two-story
frame house, badly infested with bedbugs, was during the month of
July brought to a very high degree of heat by making up good fires
in the heating furnace and other stoves in the house and closing up
the house to retain the heat. Recording thermometers placed in
different rooms indicated a gradual rise of temperature from 77° to
160° during the period from 9.30 in the morning to 7.30 in the
evening, the outside temperatures during the same period ranging
from 64° to 73° F. At 1.30, when the temperature in the different
rooms ranged from 109° to 130°, many adults and immature forms
had already succumbed. By 4.30 the temperature was ranging from
127° to 148° in different rooms, and all the insects were dead. The
continuation of the experiment was on the supposition that it would
probably require a higher degree of temperature to destroy the
eggs. The eradication of the bedbug from this house was complete,
and no damage was done to the house or its contents. That the
temperatures ranged much higher than was necessary is indicated
by the temperature experiments referred to elsewhere, which
indicated that the eggs as well as larvæ are destroyed within a few
minutes at a temperature of 113° F. The latter temperature was also
sufficient to destroy quickly the adults of fleas, cockroaches, and
other insects. It would seem, therefore, that superheating of houses
in midsummer to a temperature of 120° to 130° F. may prove to be
one of the simplest and most effective means of eradication of this
and perhaps other household pests.
[16] Ross, W. A. Eradication of the Bedbug by Superheating.
In Canadian Entomologist, vol. 48, No. 3, pp. 74-76. 1916.

ORGANIZATION OF THE UNITED STATES


DEPARTMENT OF AGRICULTURE WHEN THIS
PUBLICATION WAS LAST PRINTED
Secretary of Agriculture Henry A. Wallace.
Under Secretary Rexford G. Tugwell.
Assistant Secretary M. L. Wilson.
Director of Extension Work C. W. Warburton.
Director of Personnel W. W. Stockberger.
Director of Information M. S. Eisenhower.
Director of Finance W. A. Jump.
Solicitor Seth Thomas.
Chester C. Davis,
Agricultural Adjustment Administration
Administrator.
Bureau of Agricultural Economics Nils A. Olsen, Chief.
Bureau of Agricultural Engineering S. H. McCrory, Chief.
Bureau of Animal Industry John R. Mohler, Chief.
Bureau of Biological Survey J. N. Darling, Chief.
Bureau of Chemistry and Soils H. G. Knight, Chief.
Office of Cooperative Extension Work C. B. Smith, Chief.
Bureau of Dairy Industry O. E. Reed, Chief.
Bureau of Entomology and Plant
Lee A. Strong, Chief.
Quarantine
Office of Experiment Stations James T. Jardine, Chief.
Food and Drug Administration Walter G. Campbell, Chief.
Forest Service Ferdinand A. Silcox, Chief.
Grain Futures Administration J. W. T. Duvel, Chief.
Bureau of Home Economics Louise Stanley, Chief.
Library Claribel R. Barnett, Librarian.
Bureau of Plant Industry Knowles A. Ryerson, Chief.
Bureau of Public Roads Thomas H. MacDonald, Chief.
Weather Bureau Willis R. Gregg, Chief.

U. S. GOVERNMENT PRINTING OFFICE: 1934

For sale by the Superintendent of Documents, Washington, D. C. Price 5 cents

Transcriber Note
Illustrations move to prevent splitting paragraphs. Minor
typos may have been corrected. Produced from files
generously made available by USDA through The Internet
Archive. All resultant materials are placed in the Public
Domain.
*** END OF THE PROJECT GUTENBERG EBOOK THE BEDBUG
[1934] ***

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
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like