■
CONTENTS
ix
Aliasing Import Statements ........................................................................................................ 156
Hiding Module Names ................................................................................................................ 157
Module
Search Path, Compilation, and Loading.............................................................................. 157
Java Import Example ................................................................................................................. 157
Module Search Path and Loading............................................................................................... 158
Java Package Scanning ................................................................................................................. 158
How Jython Finds the Jars and Classes to Scan ......................................................................... 159
Compilation ............................................................................................................................... 160
Python Modules and Packages versus Java Packages.................................................................... 160
sys.path..................................................................................................................................... 160
Naming Python Modules and Packages...................................................................................... 160
Proper Python Naming ............................................................................................................... 161
Advanced Import Manipulation ....................................................................................................... 161
Import Hooks ............................................................................................................................. 161
sys.path_hooks.......................................................................................................................... 161
sys.meta_path ........................................................................................................................... 162
Summary ....................................................................................................................................... 162
Part II: Using the Language .............................................................................................................163
■
Chapter 9: Scripting With Jython................................................................................................165
Getting the Arguments Passed to a Script ...................................................................................... 165
Searching for a File ........................................................................................................................ 166
Manipulating Files.......................................................................................................................... 167
Making a Script a Module .............................................................................................................. 168
Parsing Commandline Options ....................................................................................................... 169
Compiling Java Source................................................................................................................... 170
Example Script: Builder.py ............................................................................................................. 170
HelloWorld.java .............................................................................................................................. 172
Summary ....................................................................................................................................... 173
■
Chapter 10: Jython and Java Integration ...................................................................................175
Using Java Within Jython Applications ........................................................................................... 175
Using Jython Within Java Applications ........................................................................................... 178
Object Factories......................................................................................................................... 179
One-to-One Jython Object Factories ...................................................................................... 179
Summary of One-to-One Object Factory................................................................................. 182
www.it-ebooks.info