The Definitive Guide to Jython - Python for the Java Platform (2010).pdf

(7921 KB) Pobierz
THE EXPERT’S VOICE
®
IN SOFTWARE DEVELOPMENT
Jython 2.5
Covers
The Definitive Guide to
Jython
Python for the Java
Platform
Enjoy the power and flexibility
of Python on the JVM
Josh Juneau, Jim Baker, Victor Ng,
Leo Soto, Frank Wierzbicki
Foreword by Ted Leung
The Definitive Guide to
Jython
Python for the Java™ Platform
■■■
Josh Juneau, Jim Baker, Victor Ng, Leo Soto, Frank
Wierzbicki
CONTENTS AT A GLANCE
The Definitive Guide to Jython: Python for the Java™ Platform
Copyright © 2010 by Josh Juneau, Jim Baker, Victor Ng, Leo Soto, Frank Wierzbicki
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-2527-0
ISBN-13 (electronic): 978-1-4302-2528-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of
the trademark owner, with no intention of infringement of the trademark.
Java™ and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in
the US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was
written without endorsement from Sun Microsystems, Inc.
President and Publisher: Paul Manning
Lead Editors: Steve Anglin, Duncan Parkes
Technical Reviewers: Mark Ramm, Tobias Ivarsson
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes,
Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Matt Wade, Tom Welsh
Coordinating Editor: Mary Tobin
Copy Editor: Tracy Brown Collins
Indexer: BIM Indexers and e-Services
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-ny@springer-sbm.com,
or
visit
http://www.springeronline.com.
For information on translations, please e-mail
info@apress.com,
or visit
http://www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at
http://www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any liability to any person or entity with respect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
This book is available online under the Creative Commons Attribution-Share Alike license
(http://creativecommons.org/licenses/by-sa/3.0/). You can read the book at http://jythonbook.com.
ii
Contents at a Glance
Contents at a Glance...........................................................................................................................iii
Contents ............................................................................................................................................... v
Foreword ........................................................................................................................................... xix
About the Authors .............................................................................................................................. xx
About the Technical Reviewers....................................................................................................... xxii
Acknowledgments .......................................................................................................................... xxiii
Introduction..................................................................................................................................... xxvi
Part I: Jython Basics: Learning the Language ....................................................................................1
Chapter 1: Language and Syntax ....................................................................................................3
Chapter 2: Data Types and Referencing .......................................................................................25
Chapter 3: Operators, Expressions, and Program Flow ...............................................................59
Chapter 4: Defining Functions and Using Built-ins ......................................................................81
Chapter 5: Input and Output........................................................................................................105
Chapter 6: Object-Oriented Jython .............................................................................................113
Chapter 7: Exception Handling and Debugging..........................................................................133
Chapter 8: Modules and Packages for Code Reuse ...................................................................151
Part II: Using the Language .............................................................................................................163
Chapter 9: Scripting With Jython ................................................................................................165
Chapter 10: Jython and Java Integration ...................................................................................175
Chapter 11: Using Jython in an IDE ............................................................................................197
Chapter 12: Databases and Jython: Object Relational Mapping and Using JDBC ....................231
Part III: Developing Applications with Jython ................................................................................263
Chapter 13: Simple Web Applications ........................................................................................265
Chapter 14: Web Applications With Django................................................................................281
Chapter 15: Introduction to Pylons .............................................................................................327
Chapter 16: GUI Applications ......................................................................................................347
iii
Zgłoś jeśli naruszono regulamin