Table of Contents





Click for table of contents

Table of Contents
Copyright
Full Description
About the Author
Colophon

Python Programming on Win32

Mark Hammond

Andy Robinson

Publisher: O'Reilly

First Edition January 2000
ISBN: 1-56592-621-8, 672 pages


Despite Python’s increasing popularity on Windows, Python Programming on Win32 is the first book to demonstrate how to use it as a serious Windows development and administration tool. This book addresses all the basic technologies for common integration tasks on Windows, explaining both the Windows issues and the Python code you need to glue things together.


    Preface
        About This Book
        Who Is This Book for?
        How the Book Is Organized
        About the Examples
        Font Conventions Used in This Book
        How to Contact Us
        Acknowledgments

I: Introduction to Python

    1. What Is Python?
        1.1 Language Features
        1.2 Python as an Integration Tool
        1.3 Case Studies of Python Deployment
        1.4 The Python Community
        1.5 Installation and Setup
        1.6 Conclusion

    2. Python Language Review
        2.1 A Crash Course
        2.2 Conclusion
        2.3 References

    3. Python on Windows
        3.1 The Python Core on Windows
        3.2 The Python for Windows Extensions
        3.3 The Python Imaging Library (PIL)
        3.4 PyOpenGL
        3.5 Web Publishing Tools
        3.6 The mx Extensions
        3.7 Scientific Tools
        3.8 XML
        3.9 Conclusion

    4. Integrated Development Environments for Python
        4.1 The PythonWin IDE
        4.2 IDLE
        4.3 Conclusion

    5. Introduction to COM
        5.1 What It Is
        5.2 Using COM Objects from Python
        5.3 Implementing COM Objects with Python
        5.4 Globally Unique Identifiers
        5.5 Conclusion

II: Building an Advanced Python Application

    6. A Financial Modeling Toolkit in Python
        6.1 Doubletalk
        6.2 A Crash Course in Accounting
        6.3 The Doubletalk Toolkit at Work
        6.4 Conclusion

    7. Building a GUI with COM
        7.1 Designing COM Servers
        7.2 A VB Client
        7.3 Writing a Delphi User Interface
        7.4 Conclusion

    8. Adding a Macro Language
        8.1 Dynamic Code Evaluation
        8.2 Making an Application Extensible
        8.3 Conclusion

    9. Integration with Excel
        9.1 Client-Side COM and the Excel Object Model
        9.2 Excel Concluded
        9.3 Putting It All Together: Importing Financial
            Data
        9.4 Server-Side COM Again: Excel as a GUI
        9.5 Conclusion
        9.6 References

    10. Printed Output
        10.1 Business Requirements
        10.2 Automating Word
        10.3 Direct Output to the Printer with Windows
        10.4 PIDDLE: A Python Graphics API
        10.5 PostScript
        10.6 Portable Document Format
        10.7 Putting It Together: A High-Volume Invoicing
            System
        10.8 Conclusion
        10.9 References

    11. Distributing Our Application
        11.1 DCOM
        11.2 Conclusion

III: Python on Windows Cookbook

    12. Advanced Python and COM
        12.1 Advanced COM
        12.2 Python and COM
        12.3 Using Automation Objects from Python
        12.4 Using Other COM Interfaces
        12.5 Error Handling
        12.6 Implementing COM Objects in Python
        12.7 Python and DCOM
        12.8 Conclusion

    13. Databases
        13.1 DAO, ADO, ODBC, OLEDB, and Other
            GBFLAs
        13.2 Python’s Database API
        13.3 Getting at Your Data
        13.4 A Note on Speed
        13.5 Gadfly, the Pure Python Relational Database
        13.6 Data Laundering with Python
        13.7 A Three-Tier Architecture with Business
            Objects
        13.8 Conclusion
        13.9 References

    14. Working with Email
        14.1 SMTP and POP3
        14.2 Microsoft Exchange/Outlook
        14.3 Conclusion

    15. Using the Basic Internet Protocols
        15.1 HTTP and HTML
        15.2 FTP
        15.3 NNTP
        15.4 Conclusion

    16. Windows NT Administration
        16.1 Working with Users and Groups
        16.2 Server and Share Information
        16.3 Rebooting a Machine
        16.4 Conclusion
        16.5 References

    17. Processes and Files
        17.1 Portable File Manipulation
        17.2 Native File Manipulation: The win32file
            Module
        17.3 Pipes
        17.4 Processes
        17.5 Conclusion

    18. Windows NT Services
        18.1 Services in Brief
        18.2 Controlling Services with Python
        18.3 Reading the Event Log
        18.4 Windows NT Performance Monitor Data
        18.5 Writing Services in Python
        18.6 Sample Service Written in Python
        18.7 Writing to the Event Log
        18.8 Providing Performance Monitor Information
        18.9 A Final Service
        18.10 Conclusion

    19. Communications
        19.1 Serial Communications
        19.2 Remote Access Services
        19.3 Sockets
        19.4 Other Communications Tools
        19.5 Conclusion
        19.6 References

    20. GUI Development
        20.1 Tkinter
        20.2 PythonWin
        20.3 wxPython

    21. Active Scripting
        21.1 Registering the Python Active Script Support
        21.2 Python and Popular Microsoft Applications
        21.3 Active Debugging
        21.4 How Active Scripting Works
        21.5 Active Script Hosting in Python
        21.6 Conclusion

    22. Extending and Embedding with Visual C++ and
        Delphi
        22.1 Python and Visual C++
        22.2 Simplified Wrapper and Interface Generator
        22.3 Python and Delphi
        22.4 Dynamic DLL Access
        22.5 References
        22.6 Conclusion

IV: Appendixes

    A. Key Python Modules and Functions
        A.1 Built-in Types
        A.2 Built-in Exceptions
        A.3 Built-in Functions
        A.4 module sys: System-Specific Parameters and
            Functions
        A.5 module string: Common String Operations
        A.6 module os: Miscellaneous OS Interfaces

    B. Win32 Extensions Reference
        B.1 Common Win32 Python Objects
        B.2 pythoncom Module
        B.3 win32api Module
        B.4 win32event Module
        B.5 win32evtlog Module
        B.6 win32file Module
        B.7 win32pipe Module
        B.8 win32process Module
        B.9 Service-Related Modules
        B.10 win32net Module
        B.11 USER_INFO Structures
        B.12 SERVER_INFO Structures
        B.13 GROUP_INFO Structures
        B.14 GROUP_USERS_INFO Structures
        B.15 LOCALGROUP_USERS_INFO Structures
        B.16 LOCALGROUP_INFO Structures
        B.17 LOCALGROUP_MEMBERS_INFO
            Structures

    C. The Python Database API Version 2.0
        C.1 Python Database API Specification 2.0
        C.2 Module Interface
        C.3 Connection Objects
        C.4 Cursor Objects
        C.5 Type Objects and Constructors
        C.6 Major Changes from Version 1.0 to Version 2.0
        C.7 Open Issues
        Endnotes

    D. Threads
        D.1 Python Thread Support
        D.2 Win32 Thread Support
        D.3 COM Threading Models
        D.4 What Apartment Do I Live in?
        D.5 Threads and the User Interface
        D.6 Conclusion


Python Programming on Win32

Copyright © 2000 O'Reilly & Associates, Inc. All rights reserved.

Printed in the United States of America.

Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472.

The O'Reilly logo is a registered trademark of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The use of the caiman image in association with the topic of programming Python on Win32 is a trademark of O'Reilly & Associates, Inc.

While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

Full Description

Python is growing in popularity; based on download statistics, there are now over 450,000 people using Python, and more than 150,000 people using Python on Windows. Use of the language has been growing at about 40% per year since 1995, and there is every reason to believe that growth will continue.

Despite Python's increasing popularity on Windows, Python Programming on Win32 is the first book to demonstrate how to use it as a serious Windows development and administration tool. Unlike scripting on Unix, Windows scripting involves integrating a number of components, such as COM or the various mail and database APIs, with the Win32 programming interface. While experienced Windows C++ programmers can find their way through the various objects, most people need some guidance, and this book is it. It addresses all the basic technologies for common integration tasks on Windows, explaining both the Windows issues and the Python code you need to glue things together.

Topics include:

This is a vital and unique book. Python Programming on Win32 is an excellent presentation of Windows application development and a solid illustration of how to use Python in the Windows environment.

About the Author

Mark Hammond is an independent Microsoft Windows consultant working out of Melbourne, Australia. He studied computer science at the South Australian Institute of Technology (now the University of South Australia), and then worked with several large financial institutions in Australia. He started his consulting operation in 1995.

Mark has produced many of the Windows extensions for Python, including PythonWin, Active Scripting, and Active Debugging support, and coauthored the COM framework and extensions. He is also a leading authority on Active Scripting and related technologies and has spoken on this subject at Microsoft¹s three most recent Professional Developers conferences.

Apart from being a father to his teenage daughter, having an interest in live music, and providing way-too-many free Python extensions, Mark has no life!

Andy Robinson is a London-based consultant specializing in business analysis, object-oriented design, and Windows development. He studied physics and philosophy, then Japanese studies at Oxford. He spent a year in advertising in Tokyo, two more in investment banking, and a long spell as the finance director of a startup in the sports industry. Observing that in all these positions he always ended up having to rewrite software, he moved to full-time computer consulting four years ago. He is currently helping one of the world's largest fund managers to internationalize their systems to handle Asian languages, developing Python systems for financial analysis, and reporting.

Back when Andy had spare time, his passions were track and field, and rock climbing. Right now his two sons, Tim and Harry, are taking up all of his time.


Table of Contents