7

Click here to load reader

Python Win

Embed Size (px)

Citation preview

Page 1: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 1/7

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 

About This Book

This book is about using Python to get jobs done on Windows.

We hope by now you have heard of Python, the exciting object-oriented scripting language

that is rapidly entering the programming mainstream. Although Python is perhaps betterknown on the Unix platform, it offers a superb degree of integration with the Windowsenvironment. One of us, Mark Hammond, is responsible for many of Python's Windowsextensions and has coauthored the Python COM support, both of which are major topics ofthis book. This book can thus be considered the definitive reference to date for Python onthe Windows platform.

This is intended to be a practical book focused on tasks. It doesn't aim to teach Pythonprogramming, although we do provide a brief tutorial. Instead, it aims to cover:

How Python works on Windows

The key integration technologies supported by Python on Windows, such as theWin32 extensions, which let you call the Windows API, and the support for COM

Examples in many topic areas showing what Python can do and how to put it to work

In the end, we hope you will have a clear idea of what Python can do and how to put it towork on real-world tasks.

Who Is This Book for?

I l@ve RuBoard  

I l@ve RuBoard  I l@ve RuBoard

I l@ve RuBoard

I l@ve RuBoard  

Page 1 of 7

10/15/2011file://C:\Users\honza\AppData\Local\Temp\~hh1A24.htm

Page 2: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 2/7

We expect this book to be of interest to two groups of people:

Windows developers, administrators, and IT managers  

You may be an experienced Windows developer using C++, Visual Basic, Delphi orother development tools, or you may be involved in managing information technology

(IT) and need to make decisions as to the right tools for large projects. No doubt youhear about several new languages every year and meet zealots who insist that eachis the ultimate development tool. You've perhaps heard a colleague talking aboutPython or read a few articles about it and are curious why people rave about it. By theend of this book, you should know!

Python converts from Unix  

Python is one of the major products of the Open Source revolution

( http://opensource.org/) and has a large following on Unix platforms. There are alarge number of Python users within the Unix tradition who are forced, with varying

degrees of resistance, to work in a Windows environment. We hope to open youreyes. Most of the things you do on Unix can be done on Windows, and Windowsoffers exciting programming possibilities.

Readers may vary considerably in their programming experience. We don't aim to teach thelanguage systematically and assume you are familiar with other programming languages.Someone familiar with Visual Basic, for example, should be able to follow most of the book.However, some sections regarding Windows internals or C integration assume C or C++familiarity.

We assume a fairly typical business-computing platform with Windows NT 4.0, Microsoft

Office, access to the Internet or an internal TCP/IP network, and adequate memory to runsmoothly. Python is equally happy on Windows 95 and 98, and we have tried to commenton the differences as they occur.

How the Book Is Organized

The book is broken into three parts. The first part is mainly introductory in nature and setsthe framework for the other two sections. The second section focuses on building an

advanced Windows application using Python. The main purpose of this application is toshow some possibilities for your applications. The third section provides a Python onWindows cookbook.

Part I 

This part covers the basics about the language and the platform and should be read byeveryone not familiar with using Python on Windows.

Chapter 1 

This is a Python primer: what it's good for, who's using it for what, and where to gethold of it. If you want to brief your manager on Python, show her this chapter!

I l@ve RuBoard  I l@ve RuBoard  

Page 2 of 7

10/15/2011file://C:\Users\honza\AppData\Local\Temp\~hh1A24.htm

Page 3: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 3/7

Page 4: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 4/7

This chapter shows the other side of the coin: using Python as a COM object toacquire data from and send data to Excel.

Chapter 10 

Here we cover a range of techniques for printing and for producing reports in general,

including direct printer control, automating Microsoft Word, and direct generation offinancial reports in PDF format.

Chapter 11 

Finally, we show how COM makes it extremely easy to run the Python engine on onemachine and the client interface on another.

Part III 

Each chapter in this section may be taken in isolation and covers one particular area of

interest in detail. The focus is task-based, and we look at various technologies and librariesin each section, concentrating on how to get jobs done with Python. These chaptersnaturally vary in their technical depth and appeal, but we hope that there will be plenty ofinterest for everyone.

Chapter 12 

This is the definitive reference on Python's support for COM.

Chapter 13 

This chapter shows how to connect to databases from Python and illustrates how tomanipulate data.

Chapter 14 

Here we take a look at some common techniques for dealing with email on Windows.

Chapter 15 

This is a brief discussion on how to use common Internet protocols from Python onWindows.

Chapter 16 

In this chapter, we discuss the language extensions for working with users, groups,drives, shares, servers, and so forth.

Chapter 17 

This chapter presents Python's facilities for working with processes and files, both in aportable and a Windows-specific way.

Chapter 18 

Page 4 of 7

10/15/2011file://C:\Users\honza\AppData\Local\Temp\~hh1A24.htm

Page 5: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 5/7

Page 6: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 6/7

This is interactive source code

>>>

All example code presented as source files are available for download from the authors'

web page, http://starship.python.net/crew/mhammond/ppw32/. The source codeis available as a ZIP file organized by chapter. See the web page and the README.TXT  

file in the ZIP file for more details.

Font Conventions Used in This Book

This book uses the following typographical conventions:

Italic  

Introduces new terms and indicates URLS, variables or user-defined files anddirectories, programs, file extensions, filenames, hostnames, directory or foldernames, and UNC pathnames.

Constant width

Indicates Python language elements, command-line computer output, code examples,commands, keywords, functions, modules, classes, interfaces, instances, collections,objects, properties, methods, packages, and constants.

Constant width italic 

Indicates placeholder names in syntax specifications and registry keys.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O'Reilly & Associates101 Morris StreetSebastopol, CA 95472

1-800-998-9938 (in United States or Canada)1-707-829-0515 (international or local)1-707-829-0104 (fax)

I l@ve RuBoard  I l@ve RuBoard  

This icon designates a note, which is an important aside to the nearbytext.

This icon designates a warning relating to the nearby text.

I l@ve RuBoard  I l@ve RuBoard  

Page 6 of 7

10/15/2011file://C:\Users\honza\AppData\Local\Temp\~hh1A24.htm

Page 7: Python Win

8/10/2019 Python Win

http://slidepdf.com/reader/full/python-win 7/7

You can also send us messages electronically. To be put on the mailing list or request a

catalog, send email to [email protected].

To ask technical questions or comment on the book, send email to

[email protected].

We have a web site for the book, where we list errata and any plans for future editions. Youcan find it at http://www.oreilly.com/catalog/pythonwin32/.

For more information about this book and others, see the O'Reilly web site

http://www.oreilly.com.

Acknowledgments

Although we were warned about what it takes to write a book like this, we were still notprepared! Many people contributed to this book and assisted with the enormous workload itinvolved.

The support of Guido van Rossum, the author of the Python language, for the Windowsversion of Python has enabled it to develop into a serious contender for most Windowsdevelopment work. Guido somehow manages to balance the opposing forces ofmaintaining platform independence and allowing Python to take advantage of the platform'sunique features.

The wonderful Python community also has itself to thank for allowing this book to come to

fruition. The Python newsgroup seems to be one of the final bastions of Usenet wherespams are ignored, newbies are treated kindly, and trolls are either ignored or quicklyturned into a serious and on-topic discussion. Many smart and friendly people hang out onthe newsgroup, and it's one of the more esoteric reasons many people find using thelanguage enjoyable.

The following people have provided invaluable help, whether with full reviews, in-depthknowledge of particular areas, or informal feedback: Guido van Rossum, Gordon McMillan,Greg Stein, Marc-André Lemburg, Christian Tismer, Gary Herron, Robin Dunn, Mike DaSilva, Richard Kennedy, and Damien Watkins. Many others too numerous to mention, haveplayed a part in shaping the book, whether in direct correspondence with us or in

developing and working with the packages in this book.

At O'Reilly, we'd like to thank Robert Denn, Steven Abrams, and probably a whole bunch ofother people we have never heard of.

Most important of all, Mark and Andy both wish to thank their families for their support andincredible patience, and they promise not to do this again any time soon.

I l@ve RuBoard  I l@ve RuBoard  

I l@ve RuBoard  

Page 7 of 7