Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython

Book description

Characterized by ease of use, richness of expression, and concise syntax, Python has remained a premier programming language for more than a decade, and is used by novices and professionals alike. In particular, its close relationship to Java™ makes the two languages, when used in combination, ideal for Web and distributed enterprise application development.

This tutorial begins with coverage of some of the basics of Python programming. Using plenty of skill-building exercises and interactive programming sessions, this book will help those new to programming develop an understanding of concepts and practical techniques. For experienced programmers, the book demonstrates Python's breadth of capabilities and shows the ways that Python interfaces with Java APIs for professional application development.

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython covers important topics such as:

  • Fundamental programming concepts, including statements, expressions, interpreters, and compilers

  • Python basics, including operators, string formatting, namespaces, classes, errors, and exceptions

  • Object-oriented programming concepts

  • File input/output

  • Python's intrinsic functions

  • Formatting, parsing, and manipulating strings

  • Interfacing with the Java APIs and working with Java Streams

  • Using Python and Java Swing to create GUIs

  • Working with SQL and JDBC™

  • Python and Java applets

  • In addition, the book contains instructions for downloading and installing the Python language and the Java Development Kit (JDK). Terminology, definitions, explanations, and numerous code samples make this book a useful learning experience.

    Whether you are a sophisticated computer user new to programming or a serious application developer, Python Programming with the Java™ Class Libraries will give you insight into the power of Python and the know-how to put it to work.


    Table of contents

    1. Copyright
    2. Preface
    3. Jython Overview
      1. Programming, Briefly
      2. Learning Python First
      3. Python the Language
      4. Starting with Python
      5. Basic Functions with Python
      6. Python as a Main Program
      7. The Fast Track
      8. The Power of Python
      9. Where Do You Go from Here?
      10. Summary
    4. Statements and Expressions
      1. Comments and Document Strings
      2. Statements
      3. Expressions
      4. Variables
      5. Data Types
      6. Python Collection Types
      7. Advanced Topic: Determining Types at Runtime
      8. Literals
      9. Summary
    5. Operators and String Formatting
      1. Operators
      2. Formatting Strings—Modulus
      3. Summary
    6. Control Flow
      1. The if Statement
      2. The while Statement
      3. The for Statement
      4. Putting It All Together
      5. Summary
    7. Organizing Your Code
      1. Evolution of a Programmer
      2. Code Blocks and Namespaces
      3. Modules
      4. Functions and Methods
      5. Putting Things Together
      6. Classes
      7. Packages
      8. Globals and the Global Statement
      9. Summary
    8. Object-Oriented Programming
      1. What Is OOP?
      2. Objects and Classes
      3. Special Class Methods
      4. Inheritance
      5. Polymorphism
      6. Summary
    9. Errors and Exceptions
      1. Syntax and Sequence Errors
      2. The Danger of Exceptions
      3. The try Statement
      4. The raise Statement
      5. Classes and Instances as Exceptions
      6. Getting the Most Out of Your Exceptions
      7. Summary
    10. Working with Files
      1. Simple File Operations
      2. Common File Methods
      3. Putting It All Together: The Address Book Example
      4. The Full Code
      5. Persisting Objects with pickle
      6. pickle and the Address Book Application
      7. Summary
    11. Built-In Functions
      1. Conversion
      2. Namespace: dir(), globals(), locals(), vars()
      3. Type Checking: callable(), type()
      4. Operations
      5. Advanced Topic: Functional Programming
      6. Advanced exec and eval
      7. Summary
    12. Working with Strings
      1. Conversion: atoi(), atof(), atol()
      2. Case Change: capitalize(), capwords(), swapcases(), lower(), upper()
      3. Finding: find(), rfind(), index(), rindex(), count(), replace()
      4. Splitting and Joining: split(), splitfields(), join(), joinfields()
      5. Stripping and Parsing: lstrip(), rstrip(), strip()
      6. Adjusting Text: ljust(), rjust(), center(), zfill(), expandtabs()
      7. Summary
    13. Interfacing with Java
      1. Using the Java APIs
      2. Java Types
      3. Java Constructors
      4. Java Arrays and jarray
      5. Java Arrays and Methods
      6. Bean Properties
      7. Properties
      8. Java Event Handling
      9. Subclassing Java Classes
      10. Advanced Topics
      11. Summary
    14. Working with Java Streams
      1. The Java Way of File Operations
      2. Text Streams
      3. Binary Streams: InputStream and OutputStream
      4. DataInput and DataOutput
      5. The File Class
      6. The RandomAccessFile Class
      7. The StreamTokenizer Class
      8. Persisting Objects with Java Streams
      9. Using Java Streams to Work with Memory
      10. Summary
    15. JFC Fundamentals
      1. Components and Containers
      2. JFrame
      3. Handling Events with JFrame
      4. The Python Way of Handling Events
      5. The Class Hierarchy for JFrame and Frame
      6. JPanel
      7. JLabel
      8. JComponent
      9. JButton
      10. JTextField
      11. JCheckBox
      12. JRadioButton
      13. List and JList
      14. Summary
    16. First Swing Application, Layout, and Menus
      1. Putting Things Together with Basic Java GUIs
      2. Adding an Input Form for an Address Entry: The Prototype
      3. Adding an Input Form for an Address Entry: First Cut
      4. Adding a Main Window for the Address Book Application: Prototype
      5. Adding a Main Window: First Cut
      6. Adding a Toolbar and a Dialog for the Address Book Application
      7. Menus
      8. Layout Managers
      9. A GridBagLayout Example
      10. Putting Things Together: Adding GridBagLayout to the Address Application
      11. Summary
    17. Graphics and Events
      1. A Quick Graphics Tour
      2. A Quick Tour of Common Events
      3. Putting Things Together: A Drawing Program
      4. The Complete Shapes and DrawShapes Modules
      5. Summary
    18. Advanced Swing
      1. JTable
      2. Working with Table Models
      3. Putting Things Together—Adding a Table Model to the Address Book Application
      4. JTree
      5. JToolBar and Actions
      6. Summary
    19. SQL and JDBC
      1. A Quick and Dirty JDBC Session
      2. Programming with JDBC and SQL
      3. SQL Data Definition Language
      4. SQL Data Manipulation Language
      5. Putting It All Together—Adding Database Support to the Address Book Application
      6. Summary
    20. Applets
      1. What Are Applets?
      2. Working with Applets
      3. Using an Applet as a Container
      4. Transforming the Address Book Application into an Applet
      5. Advanced Topic: AppletContext and AppletStub
      6. Summary
    21. Installing Jython on Windows
      1. Installing Java Runtime
      2. Installing the J2SE—Step by Step
      3. Installing Jython
    22. Installing Jython on Linux
      1. Unpacking the Blackdown Package
      2. Unpacking the Sun Package
      3. Installing the Sun and Blackdown Distributions
      4. Installing Older Distributions
      5. Running Jython
    23. The Power of Scripting
      1. Scripting Versus Programming Languages
      2. Java and Scripting
      3. Integrating Scripting with Jython
      4. Which Scripting Language to Choose
      5. Hello World—The Programming Rosetta Stone
      6. What Does It All Mean?
    24. Java and Python: A Comparison
      1. Python 101
      2. A GUI Application
      3. A Statistics Application
      4. A String Parsing Example
      5. Embedding Jython in Java
    25. Regular Expressions
      1. A Simple Example
      2. Pattern Characteristics
      3. Regular Expression Functions and Error and Flags Properties
      4. re Object Methods and Properties
      5. Match Object Methods and Properties
      6. Metacharacters
      7. Putting Things Together

    Product information

    • Title: Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython
    • Author(s): Richard Hightower
    • Release date: June 2002
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 0201616165