Juneau / Baker / Wierzbicki | The Definitive Guide to Jython | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 544 Seiten

Juneau / Baker / Wierzbicki The Definitive Guide to Jython

Python for the Java Platform
1. ed
ISBN: 978-1-4302-2528-7
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

Python for the Java Platform

E-Book, Englisch, 544 Seiten

ISBN: 978-1-4302-2528-7
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Jython is an open source implementation of the high-level, dynamic, object-oriented scripting language Python seamlessly integrated with the Java platform. The predecessor to Jython, JPython, is certified as 100% Pure Java. Jython is freely available for both commercial and noncommercial use and is distributed with source code. Jython is complementary to Java. The Definitive Guide to Jython, written by the official Jython team leads, covers Jython 2.5 (or 2.5.x)-from the basics to more advanced features. This book begins with a brief introduction to the language and then journeys through Jython's different features and uses. The Definitive Guide to Jython is organized for beginners as well as advanced users of the language. The book provides a general overview of the Jython language itself, but it also includes intermediate and advanced topics regarding database, web, and graphical user interface (GUI) applications; Web services/SOA; and integration, concurrency, and parallelism, to name a few.

Josh Juneau has been developing software since the mid-1990s. PL/SQL development and database programming was the focus of his career in the beginning, but as his skills developed, he began to use Java and later shifted to it as a primary base for his application development. Josh has worked with Java in the form of graphical user interface, web, and command-line programming for several years. During his tenure as a Java developer, he has worked with many frameworks such as JSF, EJB, and JBoss Seam. At the same time, Josh has extended his knowledge of the Java Virtual Machine (JVM) by learning and developing applications with other JVM languages such as Jython and Groovy. His interest in learning new languages that run on the JVM led to his interest in Jython. Since 2006, Josh has been the editor and publisher for the Jython Monthly newsletter. In late 2008, he began a podcast dedicated to the Jython programming language.

Juneau / Baker / Wierzbicki The Definitive Guide to Jython jetzt bestellen!

Weitere Infos & Material


1;The Definitive Guide to Jython;1
2;Copyright Page;2
3;Contents at a Glance;3
4;Contents;5
5;Foreword;19
6;About the Authors;20
7;About the Technical Reviewers;22
8;Acknowledgments;23
9;Introduction;26
10;PART 1 Jython Basics: Learning the Language;28
10.1;CHAPTER 1 Language and Syntax;30
10.1.1;The Difference between Jython and Python;31
10.1.2;Installing and Configuring Jython;31
10.1.3;Identifiers and Declaring Variables;32
10.1.4;Reserved Words;33
10.1.5;Coding Structure;33
10.1.6;Operators;35
10.1.7;Expressions;35
10.1.8;Functions;36
10.1.9;Classes;37
10.1.10;Statements;38
10.1.10.1;if-elif-else Statement;39
10.1.10.2;print Statement;40
10.1.10.3;try-except-finally;42
10.1.10.4;raise Statement;43
10.1.10.5;import Statement;44
10.1.11;Iteration;44
10.1.11.1;While Loop;46
10.1.11.2;For Loop;47
10.1.12;Basic Keyboard Input;47
10.1.13;Other Python Statements;48
10.1.14;Documenting Code;49
10.1.15;Python Help;50
10.1.16;Summary;51
10.2;CHAPTER 2 Data Types and Referencing;52
10.2.1;Python Data Types;52
10.2.1.1;Strings and String Methods;54
10.2.1.2;Lists, Dictionaries, Sets, and Tuples;60
10.2.1.3;Jython-specific Collections;77
10.2.1.4;Files;79
10.2.1.5;Iterators;81
10.2.1.6;Referencing and Copies;82
10.2.1.7;Garbage Collection;84
10.2.2;Summary;85
10.3;CHAPTER 3 Operators, Expressions, and Program Flow;86
10.3.1;Types of Expressions;86
10.3.2;Mathematical Operations;86
10.3.2.1;Comparison Operators;90
10.3.2.2;Bitwise Operators;92
10.3.2.3;Augmented Assignment;93
10.3.2.4;Boolean Expressions;95
10.3.2.5;Conversions;97
10.3.3;Using Expressions to Control Program Flow;99
10.3.3.1;if-elif-else Statement;99
10.3.3.2;while Loop;100
10.3.3.3;continue Statement;101
10.3.3.4;break Statement;102
10.3.3.5;for Loop;103
10.3.3.6;Example Code;104
10.3.4;Summary;106
10.4;CHAPTER 4 Defining Functions and Using Built-ins;107
10.4.1;Function Syntax and Basics;107
10.4.1.1;The def Keyword;108
10.4.1.2;Naming the Function;108
10.4.1.3;Function Parameters and Calling Functions;110
10.4.1.4;Function Body;112
10.4.2;Miscellaneous Information for the Curious Reader;116
10.4.3;Built-in Functions;116
10.4.4;Alternative Ways to Define Functions;116
10.4.4.1;Lambda Functions;117
10.4.5;Generator Functions;117
10.4.5.1;Defining Generators;118
10.4.5.2;Generator Expressions;121
10.4.6;Namespaces, Nested Scopes, and Closures;121
10.4.7;Function Decorators;122
10.4.8;Coroutines;125
10.4.8.1;Decorators in Coroutines;127
10.4.8.2;Coroutine Example;128
10.4.9;Summary;128
10.5;CHAPTER 5 Input and Output;130
10.5.1;Input from the Keyboard;130
10.5.1.1;sys.stdin and raw_input;130
10.5.1.2;Obtaining Variables from Jython Environment;131
10.5.2;File I/0;132
10.5.3;Pickle;135
10.5.3.1;Output Techniques;136
10.5.4;Summary;137
10.6;CHAPTER 6 Object-Oriented Jython;138
10.6.1;Basic Syntax;138
10.6.2;Object Attribute Lookups;142
10.6.3;Inheritance and Overloading;144
10.6.4;Underscore Methods;146
10.6.5;Protocols;148
10.6.6;Default Arguments;152
10.6.7;Runtime Binding of Methods;153
10.6.8;Caching Attribute Access;153
10.6.9;Summary;156
10.7;CHAPTER 7 Exception Handling and Debugging;158
10.7.1;Exception Handling Syntax and Differences with Java;158
10.7.1.1;Catching Exceptions;159
10.7.1.2;Raising Exceptions;167
10.7.2;Defining Your Own Exceptions;168
10.7.3;Issuing Warnings;168
10.7.4;Assertions and Debugging;173
10.7.5;Context Managers;173
10.7.6;Summary;175
10.8;CHAPTER 8 Modules and Packages for Code Reuse;176
10.8.1;Imports for Reuse;176
10.8.1.1;Import Basics;176
10.8.1.2;The Import Statement;178
10.8.2;An Example Program;178
10.8.2.1;Trying Out the Example Code;179
10.8.3;Types of Import Statements;180
10.8.3.1;From Import Statements;180
10.8.3.2;Relative Import Statements;181
10.8.3.3;Aliasing Import Statements;181
10.8.3.4;Hiding Module Names;182
10.8.4;Module Search Path, Compilation, and Loading;182
10.8.4.1;Java Import Example;182
10.8.4.2;Module Search Path and Loading;183
10.8.5;Java Package Scanning;183
10.8.5.1;How Jython Finds the Jars and Classes to Scan;184
10.8.5.2;Compilation;185
10.8.6;Python Modules and Packages versus Java Packages;185
10.8.6.1;sys.path;185
10.8.6.2;Naming Python Modules and Packages;185
10.8.6.3;Proper Python Naming;186
10.8.7;Advanced Import Manipulation;186
10.8.7.1;Import Hooks;186
10.8.7.2;sys.path_hooks;186
10.8.7.3;sys.meta_path;187
10.8.8;Summary;187
11;PART II Using the Language;188
11.1;CHAPTER 9 Scripting With Jython;190
11.1.1;Searching for a File;191
11.1.2;Manipulating Files;192
11.1.3;Making a Script a Module;193
11.1.4;Parsing Commandline Options;194
11.1.5;Compiling Java Source;195
11.1.6;Example Script: Builder.py;195
11.1.7;HelloWorld.java;197
11.1.8;Summary;198
11.2;CHAPTER 10 Jython and Java Integration;199
11.2.1;Using Java Within Jython Applications;199
11.2.2;Using Jython Within Java Applications;202
11.2.2.1;Object Factories;203
11.2.2.2;JSR-223;216
11.2.2.3;Utilizing PythonInterpreter;217
11.2.3;Summary;219
11.3;CHAPTER 11 Using Jython in an IDE;220
11.3.1;Eclipse;220
11.3.1.1;Installing PyDev;220
11.3.1.2;Minimal Configuration;221
11.3.1.3;Hello PyDev!: Creating Projects and Executing Modules;223
11.3.1.4;Passing Command-line Arguments and Customizing Execution;224
11.3.1.5;Playing with the Editor;225
11.3.1.6;A Bit of Structure: Packages, Modules, and Navigation;227
11.3.1.7;Testing;230
11.3.1.8;Adding Java Libraries to the Project;233
11.3.2;Debugging;234
11.3.2.1;Conclusion about Eclipse;236
11.3.3;Netbeans;236
11.3.4;IDE Installation and Configuration;236
11.3.5;Advanced Python Options;238
11.3.6;General Python Usage;239
11.3.7;Standalone Jython Apps;239
11.3.8;Jython and Java Integrated Apps;244
11.3.8.1;Using a JAR or Java Project in Your Jython App;244
11.3.8.2;Using Jython in Java;245
11.3.9;The Netbeans Python Debugger;246
11.3.10;Other Netbeans Python Features;251
11.3.11;Summary;252
11.4;CHAPTER 12 Databases and Jython: Object Relational Mappingand Using JDBC;253
11.4.1;ZxJDBC—Using Python’s DB API via JDBC;253
11.4.1.1;Getting Started;254
11.4.1.2;Connections;255
11.4.1.3;ZxJDBC.lookup;259
11.4.1.4;Prepared Statements;265
11.4.1.5;Resource Management;265
11.4.1.6;Metadata;266
11.4.1.7;Data Manipulation Language and Data Definition Language;267
11.4.1.8;History;271
11.4.2;Object Relational Mapping;271
11.4.2.1;SqlAlchemy;271
11.4.2.2;Installation;271
11.4.2.3;Using SqlAlchemy;272
11.4.2.4;Hibernate;276
11.4.2.5;Entity Classes and Hibernate Configuration;276
11.4.2.6;Jython Implementation Using the Java Entity Classes;278
11.4.3;Summary;283
12;PART III Developing Applications with Jython;284
12.1;CHAPTER 13 Simple Web Applications;286
12.1.1;Servlets;286
12.1.1.1;Configuring Your Web Application for Jython Servlets;287
12.1.1.2;Writing a Simple Servlet;287
12.1.1.3;Using JSP with Jython;289
12.1.2;Applets and Java Web Start;293
12.1.2.1;Coding a Simple GUI-Based Web Application;293
12.1.2.2;Distributing via Standalone JAR;297
12.1.3;WSGI and Modjy;297
12.1.3.1;Running a Modjy Application in Glassfish;298
12.1.4;Summary;301
12.2;CHAPTER 14 Web Applications With Django;302
12.2.1;Getting Django;302
12.2.2;A Quick Tour of Django;303
12.2.2.1;Starting a Project (and an “App”);304
12.2.2.2;Models;305
12.2.2.3;Bonus: The Admin;308
12.2.2.4;Views and Templates;313
12.2.2.5;Reusing Templates Without “include”: Template Inheritance;318
12.2.2.6;Forms;321
12.2.2.7;Feeds;323
12.2.2.8;Comments;325
12.2.2.9;And More...;327
12.2.3;J2EE Deployment and Integration;328
12.2.3.1;Deploying Your First Application;329
12.2.3.2;Disabling PostgreSQL Logins;329
12.2.3.3;A Note About WAR Files;330
12.2.3.4;Extended Installation;332
12.2.3.5;Connection Pooling With JavaEE;333
12.2.3.6;Dealing With Long-running Tasks;336
12.2.3.7;Thread Pools;336
12.2.3.8;Passing Messages Across Process Boundaries;339
12.2.4;Summary;346
12.3;CHAPTER 15 Introduction to Pylons;347
12.3.1;A Guide for the Impatient;347
12.3.2;A Note about Paste;349
12.3.3;Pylons MVC;349
12.3.4;An Interlude into Java’s Memory Model;350
12.3.5;Invoking the Pylons Shell;351
12.3.5.1;request.GET;352
12.3.5.2;request.POST;352
12.3.5.3;request.params;352
12.3.5.4;request.headers;353
12.3.6;Context Variables and Application Globals;353
12.3.7;Routes;353
12.3.8;Controllers and Templates;354
12.3.9;Adding a JSON API;360
12.3.10;Unit Testing, Functional Testing, and Logging;361
12.3.11;Deployment into a Servlet Container;366
12.3.12;Summary;366
12.4;CHAPTER 16 GUI Applications;367
12.4.1;Summary;377
12.5;CHAPTER 17 Deployment Targets;378
12.5.1;Application Servers;378
12.5.1.1;Tomcat;379
12.5.1.2;Glassfish;380
12.5.1.3;Other Java Application Servers;381
12.5.2;Google App Engine;381
12.5.2.1;Starting With an SDK Demo;382
12.5.2.2;Deploying to the Cloud;382
12.5.2.3;Working With a Project;383
12.5.2.4;Object Factories with App Engine;384
12.5.2.5;Using PyServlet Mapping;384
12.5.2.6;Example Jython Servlet Application for App Engine;385
12.5.2.7;Using Eclipse;388
12.5.2.8;Deploy Modjy to GAE;389
12.5.3;Java Store;389
12.5.3.1;Deploying a Single JAR;390
12.5.4;Mobile;394
12.5.5;Summary;394
13;PART IV Strategy and Technique;396
13.1;CHAPTER 18 Testing and Continuous Integration;398
13.1.1;Python Testing Tools;398
13.1.1.1;UnitTest;398
13.1.1.2;Doctests;403
13.1.1.3;A Complete Example;407
13.1.1.4;Nose;414
13.1.1.5;Integration with Java?;419
13.1.2;Continuous Integration;420
13.1.2.1;Hudson;420
13.1.2.2;Getting Hudson;420
13.1.2.3;Installing the Jython Plug-in;421
13.1.2.4;Creating a Hudson Job for a Jython Project;422
13.1.2.5;Using Nose on Hudson;426
13.1.3;Summary;429
13.2;CHAPTER 19 Concurrency;431
13.2.1;Java or Python APIs?;432
13.2.2;Working With Threads;432
13.2.3;Thread Locals;434
13.2.4;No Global Interpreter Lock;435
13.2.5;Module Import Lock;435
13.2.6;Working With Tasks;436
13.2.7;Thread Safety;440
13.2.7.1;Synchronization;441
13.2.7.2;Deadlocks;444
13.2.7.3;Other Synchronization Objects;445
13.2.7.4;Atomic Operations;449
13.2.7.5;Thread Confinement;450
13.2.8;Python Memory Model;451
13.2.9;Interruption;451
13.2.10;Summary;454
13.3;APPENDIX A Using Other Tools with Jython;455
13.3.1;The Jython Registry;455
13.3.1.1;Registry Properties;455
13.3.1.2;Finding the Registry File;456
13.3.2;Setuptools;456
13.3.3;Virtualenv;460
13.4;APPENDIX B Jython Cookbook;462
13.4.1;Logging;462
13.4.1.1;Using log4j with Jython, Josh Juneau;462
13.4.2;Working with Spreadsheets;464
13.4.2.1;Creating and Reading Spreadsheets Using Apache Poi;464
13.4.3;Jython and XML;467
13.4.3.1;Writing and Parsing RSS with ROME, Josh Juneau;467
13.4.4;Working with CLASSPATH;471
13.4.4.1;Using the CLASSPATH, Steve Langer;471
13.4.5;Ant;473
13.4.5.1;Writing Ant Tasks with Jython, Ed Takema;473
13.4.6;Developing Django Web Apps;478
13.4.6.1;Using Django in Netbeans, Josh Juneau;478
13.5;APPENDIX C Built-in Functions;480
13.5.1;Constructor Functions;480
13.5.1.1;bool([x]);480
13.5.1.2;chr(i);480
13.5.1.3;complex([real[, imag]]);481
13.5.1.4;dict([arg]);481
13.5.1.5;file(filename[, mode[, bufsize]]);481
13.5.1.6;float([x]);481
13.5.1.7;frozenset([iterable]);481
13.5.1.8;int([x[, radix]]);481
13.5.1.9;iter(o[, sentinel]);482
13.5.1.10;list([iterable]);482
13.5.1.11;object();482
13.5.1.12;open(filename[, mode[, bufsize]]);482
13.5.1.13;range([start,] stop[, step]);483
13.5.1.14;set([iterable]);483
13.5.1.15;slice([start,] stop[, step]);483
13.5.1.16;str([object]);484
13.5.1.17;tuple([iterable]);484
13.5.1.18;type(name, bases, dict);484
13.5.1.19;unichr(i);484
13.5.1.20;unicode([object[, encoding [, errors]]]);484
13.5.1.21;xrange([start,] stop[, step]);485
13.5.2;Math Built-in Functions;485
13.5.2.1;abs(x);485
13.5.2.2;cmp(x, y);485
13.5.2.3;divmod(a, b);485
13.5.2.4;pow(x, y[, z]);485
13.5.2.5;round(x[, n]);486
13.5.3;Functions on Iterables;486
13.5.3.1;all(iterable);486
13.5.3.2;any(iterable);486
13.5.3.3;enumerate(sequence[, start=0]);486
13.5.3.4;filter(function, iterable);486
13.5.3.5;map(function, iterable, ...);487
13.5.3.6;max(iterable[, key])or max([, arg, ...][, key]);487
13.5.3.7;min(iterable[, key]) or min([, arg, ...][, key]);487
13.5.3.8;reduce(function, iterable[, initializer]);487
13.5.3.9;reversed(seq);487
13.5.3.10;sorted(iterable[, cmp[, key[, reverse]]]);487
13.5.3.11;sum(iterable[, start=0]);488
13.5.3.12;zip([iterable, ...]);488
13.5.4;Conversion Functions;489
13.5.4.1;hex(x);489
13.5.4.2;long([x[, radix]]);489
13.5.4.3;oct(x);489
13.5.4.4;ord(c);489
13.5.5;Functions for Working with Code;490
13.5.5.1;classmethod(function);490
13.5.5.2;compile(source, filename, mode[, flags[, dont_inherit]]);490
13.5.5.3;eval(expression[, globals[, locals]]);491
13.5.5.4;execfile(filename[, globals[, locals]]);491
13.5.5.5;property([fget[, fset[, fdel[, doc]]]]);492
13.5.5.6;staticmethod(function);493
13.5.5.7;super(type[, object-or-type]);493
13.5.6;Input Functions;494
13.5.6.1;input([prompt]);494
13.5.6.2;raw_input([prompt]);495
13.5.7;Functions for Working with Modules and Objects;495
13.5.7.1;callable(object);495
13.5.7.2;delattr(object, name);495
13.5.7.3;dir([object]);495
13.5.7.4;getattr(object, name[, default]);496
13.5.7.5;globals();496
13.5.7.6;hasattr(object, name);496
13.5.7.7;hash(object);497
13.5.7.8;help([object]);497
13.5.7.9;id(object);497
13.5.7.10;isinstance(object, classinfo);497
13.5.7.11;issubclass(class, classinfo);498
13.5.7.12;len(s);498
13.5.7.13;locals();498
13.5.7.14;reload(module);498
13.5.7.15;repr(object);499
13.5.7.16;setattr(object, name, value);499
13.5.7.17;type(object);499
13.5.7.18;vars([object]);499
13.5.7.19;__import__(name[, globals[, locals[, fromlist[, level]]]]);500
14;Index;502



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.