O'Reilly logo

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

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced Topics

To understand what I'm going to talk about here, you should have some Java background and have read the API documentation for OutputStream.

Overriding write()

Another way to override all of write()'s forms is to override only the abstract version and then just call the others. You can also use a variable number of arguments for write() and then just use the apply() method to execute the nonabstract forms. Let me show you what I mean. (The following code is from Overload.py.)

 class OutputScreen2 (OutputStream): def write(self, *args): # If the args length is greater than one or the first # argument is not type IntType, use the apply method. if len(args) > 1 or not type(args[0]) is types.IntType: # Use the apply method to call ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required