Chapter 5. Jython Modules

Classes, functions, and variable definitions can be collected into files for easy reuse and maintenance. A file containing these kinds of definitions is referred to as a module and has a suffix of .py. In this chapter, we take a closer look at Jython modules.

Jython Module Basics

As with functions and classes, when Jython processes a module file, new global and local namespaces are defined to identify the objects that are directly accessible within the file. For example, given a simple module, as shown in Listing 5.1, how are the objects in this file used by other scripts?

Listing 5.1 Simple Module File (countdown.py)

The import Statement

The import statement is used to access the objects defined within a module ...

Get WebSphere Application Server Administration Using Jython now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.