Giter VIP home page Giter VIP logo

book's Introduction

Jython: Python for the Java Platform

Maven Central Javadocs

This is the development repository of Jython, the implementation of Python in Java. Only version 2.7 of Python can be supported at present (but watch this space for a 3.x version).

Compatibility

Jython provides good compatibility with Python 2.7 the language. Also, a high proportion of the standard library is included, taken from late versions of CPython (around 2.7.13). Some standard library modules have a Jython-specific implementation that has not kept pace with its CPython counterpart.

Jython 2.7 support for the Python ecosystem includes built-in support of pip/setuptools. You can use bin/pip if the targets do not include C extensions. There is a native launcher for Windows (bin/jython.exe) that works essentially like the python command.

Jim Baker presented a talk at PyCon 2015 about Jython 2.7, including demos of new features: https://www.youtube.com/watch?v=hLm3garVQFo

Support

Python 2.7 (the language) is no longer supported by the PSF. Running on Jython should not be considered an alternative to porting your application to Python 3, due to the limitations cited here and the small amount of effort available to support 2.7.x. Jython 2.7 is offered for continuity because a 3.x is not yet available.

See ACKNOWLEDGMENTS for details about Jython's copyright, license, contributors, and mailing lists. Consult NEWS for detailed release notes, including bugs fixed, backward breaking changes, and new features. We sincerely thank all who contribute to Jython, by bug reports, patches, pull requests, documentation changes and e-mail discussions.

Downloads

Binary downloads are available from https://www.jython.org/download along with Maven and Gradle dependency information.

How to build Jython

The project uses Git for version-control, and the master repository is at https://github.com/jython/jython, You should clone this repository to create a buildable copy of the latest state of the Jython source. Start a new branch for any bug-fix or experimentation you plan.

The previously authoritative repository at https://hg.python.org/jython is not now in use, remaining frozen at v2.7.2.

Build using ant for development

Jython is normally built using ant. It is necessary to have Ant and at least a Java 8 SDK on the path. To build Jython in development, we generally use the command:

ant

This leaves an executable in dist/bin that you may run from the check-out root with:

dist/bin/jython

Other ant targets exist, notably clean, javatest and jar.

You can test your build of Jython (by running the regression tests), with the command:

dist/bin/jython -m test.regrtest -e -m regrtest_memo.txt

or by invoking the Ant target regrtest.

Build an installer using ant

If you want to install a snapshot build of Jython, use the command:

ant installer

This will leave you with a snapshot installer JAR in dist, that you can run with:

java -jar jython-installer.jar

for the graphical installer, or:

java -jar jython-installer.jar --console

For the console version. (A --help option gives you the full story.)

Build a JAR using Gradle

We have a Gradle build that results in a family of JARs and a POM. This is intended to provide the Jython core in a form that Gradle and Maven users can consume as a dependency. Invoke this with:

PS> .\gradlew publish

and a JAR and POM are delivered to .build2\repo

Whereas the JARs delivered by the installer are somewhat "fat", embedding certain dependencies in shaded (renamed) form, the JAR from the Gradle build is "spare" and cites its dependencies externally through a POM.

book's People

Contributors

adamburkegh avatar agronholm avatar fwierzbicki avatar jeff5 avatar jimbaker avatar juneau001 avatar leosoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

book's Issues

Use logical chapter names

Use naming like 01-language-and-syntax.rst instead of chapter1.rst. Lexicographical ordering is preserved (currently it is lost due to chapter1 vs chapter10), while allowing people to more readily find a specific chapter to edit.

Code examples contain Non-ASCII character

When trying out code examples by copy & paste it from the browser into a sourcecode editor that uses UTF-8 by default, you at first don't recognize that some code examples contain non ASCII characters, which results in the error message

  File "<string>", line None
SyntaxError: Non-ASCII character in file 'wrong_encoding.py', but no encoding declared; se
see http://www.python.org/peps/pep-0263.html for details

This is very confusing for beginners , time consuming to figure out and breaks the flow when learning. When you switch the encoding of the file to ASCII, you then can see the error. The code examples actually use the wrong character, the minus in that case is not the real minus character, its dash from UTF-8 charset:

image

The example shown is from chapter 1, break statement:
https://jython.readthedocs.io/en/latest/chapter1/#break-statement

I also had a similar error with "sports team" example in chapter 3.
https://jython.readthedocs.io/en/latest/chapter3/#example-code

Errata Chapter 8: Modules and Packages

"The code for this program can be downloaded at XXX." -> so i created that on my own, see https://github.com/heywiki/jython-book-examples/tree/master/chapter7

what i discovered:

users have to start the program not by scanner.py like described, but by

jython searchdir.py . term

In searchdir.py you have to call a static method on ScanResults: scanner.ScanResults.scan(), not an object one, and exit() was not working, had to use sys.exit()

#from scanner import ScanResults
import search.scanner as scanner
import sys

help = """
Usage: search.py directory terms...
"""

args = sys.argv

if args == None or len(args) < 2:
    print help
    sys.exit()

dir = args[1]
terms = args[2:]
scan = scanner.ScanResults.scan(dir, terms)
scan.display()

Accordingly you have to add the @staticmethod annotation to ScanResults.scan

from search.walker import DirectoryWalker
from javax.swing import JFrame, JTable, WindowConstants

class ScanResults(object):
    def __init__(self):
        self.results = []

    def add(self, file, line):
        self.results.append((file, line))

    def display(self):
        colnames = ['file', 'line']
        table = JTable(self.results, colnames)
        frame = JFrame("%i Results" % len(self.results))
        frame.getContentPane().add(table)
        frame.size = 400, 300
        frame.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
        frame.visible = True

    @staticmethod
    def scan(dir, terms):
        results = ScanResults()
        for filename in DirectoryWalker(dir):
            for line in open(filename):
                for term in terms:
                    if term in line:
                        results.add(filename,line)
        return results

Merge changes from Josh Juneau's copy

I have found a later version of the book in a repo belonging to Josh Juneau than the one we are building on. :( This version is much closer to the paper edition.

It will take some careful work to merge Josh's into this repository, because of fixes made here that that version lacks. (I think that's the right thing to do, but only trying will tell us if it's a lost cause.)

Believe it or not, I actually found this via the unfinished Korean translation on RTD, which I spotted contained stuff we didn't have.

Code examples are not included correctly.

At least in Chapter 19 (did not check the other chapters) most code examples are not included correctly. Instead there is a message box like ".. literalinclude:: src/chapter19/threadsafety.py"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.