SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Jython
Python for Java Platform
Agenda
❖ History
❖ Introduction
❖ Installation
❖ Jython Console
❖ Jython Basic Datatypes
❖ Collections
❖ Modules and Importing
❖ Functions
History
It was initially created in late 1997 to replace C with Java for performace
intensive.
It moves to SourceForge in October, 2000.
The Python Software Foundation awarded a grant in January 2005.
Jython 2.5 was released in June 2009
Introduction
● Python is an easy to learn, powerful programming language.
● Jython is an implementation of Python for the JVM.
● It takes the Python programming languages syntax and enables it to run
on the Java Platform.
● Most of the Python modules will run without changes under Jython, but if
they use extensions then they will probably not work.
Why Jython
1. Embedded Scripting
2. Ability to extend existing Java classes
3. Optional static compilation
4. Bean Properties
5. Python Language
There are certain libraries written in Java languages to be included with Jython
(especially modules written in C).
● Introduction
● Built-in Functions
● Built-in Constants
● Built-in Objects
● Built-in Types
● Built-in Exceptions
● String Services
● Data Types
● Numeric and Mathematical
Modules
● File and Directory Access
● Data Persistence
● Data Compression and
Archiving
● File Formats
● Cryptographic Services
● Generic Operating System
Service
● Optional Operating System
● Interprocess Communication
and Networking
● Many More...
Installation
Download Jython 2.7 and execute below command to start installation GUI.
java -jar jython_installer-2.*.*.jar
We can add --console to start the installation in non GUI.
JYTHON_HOME=/home/vijay/jython2.7.0; export JYTHON_HOME
PATH=$PATH:$JYTHON_HOME/bin
Jython
Jython Basic Data Type
● It sees everything, including all data and code, as an object.
● Jython Types Summary
● Common Operators
● Boolean Types
● Numeric Types
● Additional Methods and Operations
Jython Collections
It supports two major types of collections
1. Sequence Types (Order Collection of items)
2. Map Type
Sequence Types
1. All sequences are zero-indexed. It is similar to C and Java Arrays.
2. All sequences support indexing (or subscripting) to select sub-elements.
3. It support an extension of indexing, called slicing, which selects a range of
elements.
4. It also support reverse slicing.
5. Slicing Reference
6. Sequence Operators
7. Sequence Function
Strings
1. A string is an immutable sequence of characters treated as a value.
2. String Methods
3. It doesn’t have a character type. Character are represented by strings of
length one.
4. Escape Character
5. Format Code
Tuples
1. Tuples are immutable lists of any type.
2. It can be of any length and can contain any type of object.
3. Tuple Example
Ranges
1. Jython uses immutable sequence of increasing integers, called ranges.
2. It can be easily created by
a. range({start}, end,{inc}) creates a small range. All element of the range exist.
b. xrange({start}, end, {inc}) creates a large range. Elements are created only as needed.
3. Default start is 0 and default inc is 1.
Lists
1. Lists Method
2. We can use List as Stack and Queue.
3. Stack is easy to implement using append() and pop().
4. To implement Queue we use collections.queue
5. It can also be created via advance notation, called list comprehensions.
Map and Dictionaries
We work only with subtypes of Map. Most commonly we used dictionary.
Dictionary Example
Modules and Importing
● Jython breaks program down into separate files, called modules.
● Jython Modules Library
● A module is an executable Jython file that contains definitions.
● Jython packages are implemented as directories that can contain one or
more than one modules and a special file __init__.py, that executed before
first module of the package is executed.
● import module {as alias} OR from module import name {as alias}
● From module import *
● Import is executable
Math Module Examples
Other Important Stuff
Exception
Procedural Statement
Jython Functions
1. Functions
Blocks of code that return values (called functions)
2. Subroutines
Blocks that don’t return values
Functions are declared by def statement.
def name ( args ): statement -- or -- def name ( args ): block
● Specifying Function Argument
● Anonymous Function
● Generic Function
● Nested Function
● Functional Programming
Sample Application
References
● http://imagej.net/Jython_Scripting_Examples
● https://www.ibm.com/developerworks/java/tutorials/j-jython1/j-jython1.h
tml
● https://dzone.com/articles/embed-jython-to-your-java-codebase

Weitere ähnliche Inhalte

Was ist angesagt?

Developing Multithreaded Applications
Developing Multithreaded ApplicationsDeveloping Multithreaded Applications
Developing Multithreaded Applications
Bharat17485
 
12 multi-threading
12 multi-threading12 multi-threading
12 multi-threading
APU
 
Thread model of java
Thread model of javaThread model of java
Thread model of java
myrajendra
 
Synchronization.37
Synchronization.37Synchronization.37
Synchronization.37
myrajendra
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
parag
 

Was ist angesagt? (18)

Developing Multithreaded Applications
Developing Multithreaded ApplicationsDeveloping Multithreaded Applications
Developing Multithreaded Applications
 
Review of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iiiReview of c_sharp2_features_part_iii
Review of c_sharp2_features_part_iii
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
 
12 multi-threading
12 multi-threading12 multi-threading
12 multi-threading
 
Java threads
Java threadsJava threads
Java threads
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Thread model of java
Thread model of javaThread model of java
Thread model of java
 
L22 multi-threading-introduction
L22 multi-threading-introductionL22 multi-threading-introduction
L22 multi-threading-introduction
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 
Synchronization.37
Synchronization.37Synchronization.37
Synchronization.37
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java threads
Java threadsJava threads
Java threads
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRao
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
Multithread Programing in Java
Multithread Programing in JavaMultithread Programing in Java
Multithread Programing in Java
 

Ähnlich wie Jython

Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Devloper
 

Ähnlich wie Jython (20)

python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
 
Python
PythonPython
Python
 
Python intro
Python introPython intro
Python intro
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Modules in Python
Modules in PythonModules in Python
Modules in Python
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask Training
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx
 
Python for katana
Python for katanaPython for katana
Python for katana
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdfPYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 

Mehr von Vijay Shukla

Mehr von Vijay Shukla (20)

Introduction of webpack 4
Introduction of webpack 4Introduction of webpack 4
Introduction of webpack 4
 
Preview of Groovy 3
Preview of Groovy 3Preview of Groovy 3
Preview of Groovy 3
 
Groovy closures
Groovy closuresGroovy closures
Groovy closures
 
Groovy
GroovyGroovy
Groovy
 
Grails services
Grails servicesGrails services
Grails services
 
Grails plugin
Grails pluginGrails plugin
Grails plugin
 
Grails domain
Grails domainGrails domain
Grails domain
 
Grails custom tag lib
Grails custom tag libGrails custom tag lib
Grails custom tag lib
 
Grails
GrailsGrails
Grails
 
Gorm
GormGorm
Gorm
 
Controller
ControllerController
Controller
 
Config BuildConfig
Config BuildConfigConfig BuildConfig
Config BuildConfig
 
Command object
Command objectCommand object
Command object
 
Boot strap.groovy
Boot strap.groovyBoot strap.groovy
Boot strap.groovy
 
Vertx
VertxVertx
Vertx
 
Custom plugin
Custom pluginCustom plugin
Custom plugin
 
Spring security
Spring securitySpring security
Spring security
 
REST
RESTREST
REST
 
Config/BuildConfig
Config/BuildConfigConfig/BuildConfig
Config/BuildConfig
 
GORM
GORMGORM
GORM
 

Kürzlich hochgeladen

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 

Kürzlich hochgeladen (20)

The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 

Jython

  • 2. Agenda ❖ History ❖ Introduction ❖ Installation ❖ Jython Console ❖ Jython Basic Datatypes ❖ Collections ❖ Modules and Importing ❖ Functions
  • 3. History It was initially created in late 1997 to replace C with Java for performace intensive. It moves to SourceForge in October, 2000. The Python Software Foundation awarded a grant in January 2005. Jython 2.5 was released in June 2009
  • 4. Introduction ● Python is an easy to learn, powerful programming language. ● Jython is an implementation of Python for the JVM. ● It takes the Python programming languages syntax and enables it to run on the Java Platform. ● Most of the Python modules will run without changes under Jython, but if they use extensions then they will probably not work.
  • 5. Why Jython 1. Embedded Scripting 2. Ability to extend existing Java classes 3. Optional static compilation 4. Bean Properties 5. Python Language
  • 6. There are certain libraries written in Java languages to be included with Jython (especially modules written in C). ● Introduction ● Built-in Functions ● Built-in Constants ● Built-in Objects ● Built-in Types ● Built-in Exceptions ● String Services ● Data Types ● Numeric and Mathematical Modules ● File and Directory Access ● Data Persistence ● Data Compression and Archiving ● File Formats ● Cryptographic Services ● Generic Operating System Service ● Optional Operating System ● Interprocess Communication and Networking ● Many More...
  • 7. Installation Download Jython 2.7 and execute below command to start installation GUI. java -jar jython_installer-2.*.*.jar We can add --console to start the installation in non GUI. JYTHON_HOME=/home/vijay/jython2.7.0; export JYTHON_HOME PATH=$PATH:$JYTHON_HOME/bin
  • 9.
  • 10. Jython Basic Data Type ● It sees everything, including all data and code, as an object. ● Jython Types Summary ● Common Operators ● Boolean Types ● Numeric Types ● Additional Methods and Operations
  • 11. Jython Collections It supports two major types of collections 1. Sequence Types (Order Collection of items) 2. Map Type
  • 12. Sequence Types 1. All sequences are zero-indexed. It is similar to C and Java Arrays. 2. All sequences support indexing (or subscripting) to select sub-elements. 3. It support an extension of indexing, called slicing, which selects a range of elements. 4. It also support reverse slicing. 5. Slicing Reference 6. Sequence Operators 7. Sequence Function
  • 13. Strings 1. A string is an immutable sequence of characters treated as a value. 2. String Methods 3. It doesn’t have a character type. Character are represented by strings of length one. 4. Escape Character 5. Format Code
  • 14. Tuples 1. Tuples are immutable lists of any type. 2. It can be of any length and can contain any type of object. 3. Tuple Example
  • 15. Ranges 1. Jython uses immutable sequence of increasing integers, called ranges. 2. It can be easily created by a. range({start}, end,{inc}) creates a small range. All element of the range exist. b. xrange({start}, end, {inc}) creates a large range. Elements are created only as needed. 3. Default start is 0 and default inc is 1.
  • 16. Lists 1. Lists Method 2. We can use List as Stack and Queue. 3. Stack is easy to implement using append() and pop(). 4. To implement Queue we use collections.queue 5. It can also be created via advance notation, called list comprehensions.
  • 17. Map and Dictionaries We work only with subtypes of Map. Most commonly we used dictionary. Dictionary Example
  • 18.
  • 19. Modules and Importing ● Jython breaks program down into separate files, called modules. ● Jython Modules Library ● A module is an executable Jython file that contains definitions. ● Jython packages are implemented as directories that can contain one or more than one modules and a special file __init__.py, that executed before first module of the package is executed. ● import module {as alias} OR from module import name {as alias} ● From module import * ● Import is executable
  • 22. Jython Functions 1. Functions Blocks of code that return values (called functions) 2. Subroutines Blocks that don’t return values Functions are declared by def statement. def name ( args ): statement -- or -- def name ( args ): block
  • 23. ● Specifying Function Argument ● Anonymous Function ● Generic Function ● Nested Function ● Functional Programming
  • 25.