Home > Store

Python Developer's Handbook

Register your product to gain access to bonus material or receive a coupon.

Python Developer's Handbook

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2000
  • Dimensions: 7-3/8" x 9-1/8"
  • Pages: 960
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-31994-2
  • ISBN-13: 978-0-672-31994-5

The Python Developer's Handbook is designed to expose experienced developers to Python and its uses. Beginning with a brief introduction to the language and its syntax, the book moves quickly into more advanced programming topics, including embedding Python, network programming, GUI toolkits, JPython, Web development, Python/C API, and more. Python is an interpreted, object-oriented programming language. Its syntax is simple and easy to learn, and it encourages programmers to write and think clearly. The Python Developer's Handbook is carefully written, well-organized introduction to this powerful, fast-growing programming language for experienced developers.

Downloads

Downloads


Source code for the book in ZIP format -- 180 kb -- code.zip
Source code for the book in tar/gzip format -- 153 kb -- code.tar.gz
Source code for the book in tar/compress format -- 224 kb -- code.tar.z

Sample Content

Table of Contents



Introduction.

I. BASIC PROGRAMMING.

1. Introduction.

Introduction to Python.

Python!? What Is It?

Why Use Python?

Readability. It Is Simple to Get Support. Fast to Learn. Fast to Code. Reusability. Portability. Object-Oriented Programming. Overall Conclusion.

Main Technical Features.

Automatic Memory Management. Exception Handling. Rich Core Library. Web Scripting Support and Data Handling. Built-In Elements. Development Flow. Clear Syntax and a Diversity of Useful Lexical Elements. Embeddable and Extendable. Objects Distribution. Databases. GUI Application. Introspection. Third-Party Projects Integration.

Python Distribution.

System Requirements.

Installing and Configuring Python.

UNIX Environment. Macintosh Environment. Windows Environment.

Python and Other Languages.

Python Versus C/C++. Python Versus Perl. Python Versus Tcl. Python Versus Smalltalk. Python Versus Java. Conclusion.

Patches and Bugs List. PSA and the Python Consortium.

Support and Help. Python Conferences and Workshops.

Summary.

2. Language Review.

Language Review. The Shell Environment.

Command Line Interpreter.

Programs.

Indentation. Lexical Analysis. Reserved Words. Identifiers.

Built-In Data Types.

Immutable Data Types. Mutable Data Types. Numbers. Strings. True and False Logical Values.

Operators.

Augmented Assignment.

Expressions.

Built-In Functions. Sequence Functions. Object Manipulation. Mathematical/Logical Functions. Code Functions. Type Conversion.

Control Statements.

if/elif/else. for. while. break/continue.

Data Structures.

Lists. Built-In Methods. Ranges. Tuples. Dictionaries (hash tables).

Functions and Procedures.

Functions. Dynamic Namespace.

Modules and Packages.

Built-In Methods. from in Contrast to import. Releasing and Reloading Modules.

Input and Output.

Displaying Information. Formatting Operations.

File Handling.

Opening a File. Supported Methods. File Object Attributes.

Summary. Code Example.

3. Python Libraries.

Python Libraries.

The Library Reference. The Standard Library of Modules.

Python Services.

sys. types. UserDict. UserList. operator. traceback. linecache. pickle. cPickle. copy_reg. shelve. copy. marshal. imp. parser. symbol. token. keyword. tokenize. pyclbr. code. codeop. pprint. repr. py_compile. compileall. dis. new. site. user. __builtin__. __main__.

The String Group.

string. re. regex. regsub. struct fpformat. StringIO. cStringIO.

Miscellaneous.

math. cmath. random. whrandom. bisect. array. ConfigParser. fileinput. calendar. cmd. shlex.

Generic Operational System.

os. os.path. dircache. stat. statcache. statvfs. cmp cmpcache. time. sched. getpass. curses. getopt. tempfile. errno. glob. fnmatch. shutil. locale. mutex.

Optional Operational System.

signal. socket. select. thread. threading. Queue. anydbm. dumbdbm. dbhash. whichdb. bsddb. zlib. gzip. rlcompleter.

Debugger. Profiler. Internet Protocol and Support.

cgi. urllib. httplib. ftplib gopherlib. poplib. imaplib. nntplib. smtplib. telnetlib. urlparse. SocketServer. BaseHTTPServer. SimpleHTTPServer. CGIHTTPServer. asyncore.

Internet Data Handling.

sgmllib. htmllib. htmlentitydefs. xmllib. formatter. rfc822. mimetools. MimeWrite. multifile. binhex. uu. binascii. base64. xdrlib. mailcap. mimetypes. quopri. mailbox. mhlib. mimify. netrc.

Restricted Execution.

rexec. Bastion.

Multimedia.

audioop. imageop. aifc. sunau. wave. chunk. colorsys. rgbimg. imghdr. sndhdr.

Cryptographic.

md5. sha. mpz. rotor.

UNIX Specific.

posix. pwd. grp. crypt. dlmodule. dbm. gdbm. termios. TERMIOS. tty. pty. fcntl. pipes. posixfile. resource. nis. syslog. popen2. commands.

SGI IRIX Specific.

al. AL. cd. fl. FL. flp. fm. gl. DEVICE. GL. imgfile. jpeg.

Sun OS Specific.

sunaudiodev. SUNAUDIODEV.

MS Windows Specific.

msvcrt. winsound.

Macintosh Specific.

findertools. macfs. macostools.

Undocumented Modules.

Frameworks. Miscellaneous Useful Utilities. Platform Specific Modules. Multimedia. Obsolete. Extension Modules. New Modules on Python 2.0.

Summary.

Python Services. The String Group. Miscellaneous. Generic Operational System. Optional Operational System. Debugger. Profiler. Internet Protocol and Support. Internet Data Handling. Restricted Execution. Multimedia. Cryptographic. OS Specific (UNIX, SGI IRIX, SUN OS, MS Windows, and Macintosh). Undocumented Modules. New Modules in Python 2.0.

4. Exception Handling.

Exception Handling. Standard Exceptions (Getting Help from Other Modules). Raising Exceptions.

Raising an Exception to Leave the Interpreter. Raising an Exception to Leave Nested Loops. Raising String Exceptions. Instancing an Exception Class. Debugging Your Code.

Catching Exceptions.

Catching Standard Errors.

try/finally. Creating User-defined Exceptions. The Standard Exception Hierarchy. Summary. Code Examples.

5. Object-Oriented Programming.

Object-Oriented Programming. An Introduction to Python OOP.

Class Instances.

Python Classes and Instances.

Attributes of a Class. The Python Class Browser. Python Instances.

Methods Handling.

Accessing Unbounded Methods. Handling Global Class Variables. Calling Methods from Other Methods.

Special Methods.

Method Attributes. Overloading Operators.

Inheritance. Polymorphism. Encapsulation. Metaclasses. Summary. Code Examples.

II. ADVANCED PROGRAMMING.

6. Extending and Embedding Python.

Extending and Embedding Python. The Python/C API. Extending.

Creating New Extensions. Importing an Extension Module. Formatting Strings. Exporting Constants. Error Checking. Reference Counting. Building Extensions in C++.

Compiling and Linking Extension Modules.

Linking Static Extensions to the Interpreter. Linking Dynamic Extensions to the Interpreter.

SWIG-The Simple Wrapper Interface Generator. Other Wrappers. Embedding.

Implementing Callback Functions. Embedding the Python Interpreter. Embedding Python in C++. Embedding Python in Other Applications.

Summary. Code Examples.

Wrapping C Functions.

7. Objects Interfacing and Distribution.

Object Interfacing and Distribution. Interfacing Objects. Introduction to COM Objects.

The COM Specification. COM Interfaces. ADO. ActiveX.

Implementing COM Objects in Python.

The win32com Package. Talking to Windows Applications. Word and Excel. Visual Basic. Delphi.

Distributing Objects with Python.

Inter-Language Unification (ILU). CORBA Binding and Implementation. Fnorb. DCOM. OMF. Hector.

Summary. Code Examples.

Parking Lot (File parkinglot.py).

8. Working with Databases.

Working with Databases. Flat Databases.

Text Data. Binary Data-The struct Module.

DBM (Database Managers) Databases.

dbm Module. gdbm Module. bsddb Module. dbhash Module. anydbm Module. dumbdbm Module. whichdb Module.

Object Serialization and Persistent Storage.

pickle Module. cPickle Module. copy_reg Module. marshal Module. shelve Module. More Sources of Information.

The ODBC Module.

mxODBC. calldll. unixODBC. Other Interesting ODBC Web Pages.

ADO (ActiveX Data Objects). Using SQL.

SQL Mini-Tutorial. PostgreSQL Databases. MySQL Modules. The GadFly SQL Module. MetaKit Database Engine.

Python DB API.

DB-API Specification v2.0.

Summary.

9. Other Advanced Topics.

Other Advanced Topics. Manipulating Images.

Python Imaging Library. Other Modules.

Working with Sounds.

winsound Module. sndhdr Module. wave Module. aifc Module. audiodev Module.

Restricted Execution Mode.

Protecting the Application Environment.

Scientific Computing.

Numerical Extensions. Other Scientific Extensions. Computer Programming for Everybody.

Regular Expressions.

Regular Expression Functions and Object Methods.

Threads.

Python Threads. Python Thread Modules. Microthreads.

Summary. Code Examples.

HTML Parsing Tool (File: parsing.py). TV Network Audiences (File: audience.py).

III. NETWORK PROGRAMMING.

10. Basic Network Background.

Networking. Networking Concepts.

Protocols. Addresses. Sockets.

HTTP.

M2Crypto, by Ng Pheng Siong's. CTC (Cut The Crap), by Constantinos Kotsokalis. Alfajor, by Andrew Cooke. Building Web Servers. Setting Up the Client Side of the HTTP Protocol.

Accessing URLs.

The urllib Module. The urlparse Module.

FTP.

Transferring Data.

SMTP/POP3/IMAP.

Handling Email Services.

Newsgroups-Telnet and Gopher. Summary.

11. Web Development.

Web Development. Configuring Web Servers for Python/CGI Scripts.

Python in Apache. AOLserver Web Server. Microsoft IIS and PWS.

Third-Party Internet Applications.

Grail Web Browser. Zope Web Application Server. Mailman-GNU Mailing List Manager. Medusa Internet Server.

Other Applications.

BSCW. LDAP. WebLog.

Site Management Tools.

WebDAV/PyDAV. Zebra. httpd_log. Linbot. Python-Friendly Internet Solution Providers (ISPs). mxCGIPython. HTMLgen. Document Template. Persistent CGI. Webchecker. LinkChecker. FastCGI.

Summary.

12. Scripting Programming.

Web Programming. An Introduction to CGI. The cgi Module.

Functions.

Creating, Installing, and Running Your Script.

Sending Information to Python Scripts. Working with Form Fields and Parsing the Information. Security. Sessions. Data Storage. Locking. Cookies. Creating Output for a Browser. Uploading/Uploaded Files. Environment Variables. Debugging and Testing Your Script.

Python Active Scripting.

Using COM Objects. ASP and Microsoft ActiveX Scripting. Python Server Pages.

Summary.

13. Data Manipulation.

Parsing and Manipulating Data. XML Processing.

Introduction to XML. Writing an XML File. Python XML Package. xmllib. The SAX API. DOM: The Document Object Model. XSL Transformations (XSLT). XBEL-XML Bookmark Exchange Language. RPC-What Is It? Simple Object Access Protocol (SOAP). PythonPoint. Pyxie.

XML-RPC.

The Python Implementation. Working with Zope.

XDR Data Exchange Format.

xdrlib.

Handling Other Markup Languages.

sgmllib. htmllib. htmlentitydefs. formatter.

MIME Parsing and Manipulation.

rfc822. mimetools. MimeWriter. multifile. mailcap. mimetypes. base64. quopri. mailbox. mimify.

Generic Conversion Functions.

netrc. mhlib. binhex. uu. binascii.

Summary.

IV. GRAPHICAL INTERFACES.

14. Python and GUIs.

Python GUI Toolkits. The Tkinter Module. Overview of Other GUI Modules.

Pythonwin/MFC. wxPython. STDWIN. PyKDE. Wpy. PyGTK. PyOpenGL. wafepython. pyFLTK. FXPy. Motif. PyAmulet. DynWin. JPI. FORMS.

Designing a Good Interface. Summary.

15. Tkinter.

Introduction to Tcl/Tk. Tkinter.

Checking the Installation. Hello Python World.

Geometry Management.

pack(). grid(). place().

Handling Tkinter Events.

Mouse Events. Keyboard Events. Event Attributes. Event Callbacks. Protocols.

Tkinter Widgets.

Widget Standard Options. Widgets Reference. General Widget Methods.

Designing Applications. PMW-Python Mega Widgets. Tkinter Resources. Summary.

V. DEVELOPING WITH PYTHON.

16. Development Environment.

Building Python Applications. Development Strategy.

Optimizing the Code. Style Guide.

Integrated Development Environments. IDLE.

Installing and Configuring IDLE. Python Shell. File Menu. Edit Menu. Writing an IDLE Extension. Python 2.0 and IDLE.

Pythonwin.

The Pythonwin Environment. Keyboard Bindings.

Summary.

17. Development Tools.

The Development Process of Python Programs. Compiling Python.

Windows. UNIX.

Editing Code.

Emacs.

Python Scripts. Generating an Executable Python Bytecode. Interpreter. Debugging the Application.

The Base Debugger Module (bdb). The Python Debugger (pdb). Disassembling Python Bytecodes.

Profiling Python.

Python Profiler. Analyzing Profiles with the pstats Module.

Distributing Python Applications.

SqueezeTool. Python2C-The Python to C Translator. Small Python. Gordon McMillan's Installer. Distutils.

Summary.

VI. PYTHON AND JAVA.

18. JPython.

Welcome to JPython.

JPython Features. CPython Versus Jpython. JPython Resource Links.

Java Integration.

Java Certification. Java Links.

Downloading and Installing JPython.

Downloading the CPython Library. Licensing. JVMs That Support JPython.

The Interpreter. The JPython Registry.

Registry Properties. Finding the Registry File.

Creating Graphical Interfaces. Embedding.

JPython in a Java Application. Java in a JPython Application.

jpythonc. Running JPython Applets. Summary.

VII. APPENDIXES.

Appendix A. Python/C API.

Python/C API.

Include Files. Objects, Types, and Reference Counts. Exceptions. Embedding Python.

The Very High Level Layer. Reference Counting. Exception Handling. Standard Exceptions.

Deprecation of String Exceptions.

Utilities.

OS Utilities. Process Control. Importing Modules.

Abstract Objects Layer.

Object Protocol. Number Protocol. Sequence Protocol. Mapping Protocol.

Concrete Objects Layer.

Fundamental Objects. Sequence Objects. Mapping/Dictionary Objects. Numeric Objects. Other Objects.

Initialization, Finalization, and Threads.

Thread State and the Global Interpreter Lock.

Memory Management.

Memory Interface. Examples.

Defining New Object Types.

Common Object Structures. Mapping Object Structures. Number Object Structures. Sequence Object Structures. Buffer Object Structures.

Appendix B. Running Python on Specific Platforms.

Python on Win32 Systems. Python on MacOS Systems. Python on UNIX Systems. Other Platforms.

Python for OS/2. Python for Windows 3.1. Python for DOS. Python for BeOS. Python for VMS. Python for Psion. Python for Windows CE. Python for Anything Else.

Appendix C. Python Copyright Notices.

Python 2.0 License Information.

HISTORY OF THE SOFTWARE.

Python's Copyright Notice (version 1.6). Python's Copyright Notice (until version 1.5.2). Copyright Notice of the profile and pstats Modules. Copyright Notice of JPython with OROMatcher. Copyright Notice of JPython without OROMatcher.

Appendix D. Migrating to Python 2.0.

Python 1.6 or Python 2.0. Which One to Choose? New Development Process. Enhancements.

Unicode Support. List Comprehension. Strings Manipulation. Augmented Assignment. Garbage Collection. Maximum Recursion.

Expected Code Breaking.

Index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020