SlideShare a Scribd company logo
1 of 26
Download to read offline
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

More Related Content

What's hot

Developing Multithreaded Applications
Developing Multithreaded ApplicationsDeveloping Multithreaded Applications
Developing Multithreaded ApplicationsBharat17485
 
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_iiiNico Ludwig
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and ConcurrencySunil OS
 
12 multi-threading
12 multi-threading12 multi-threading
12 multi-threadingAPU
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaArafat Hossan
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javajunnubabu
 
Thread model of java
Thread model of javaThread model of java
Thread model of javamyrajendra
 
L22 multi-threading-introduction
L22 multi-threading-introductionL22 multi-threading-introduction
L22 multi-threading-introductionteach4uin
 
Synchronization.37
Synchronization.37Synchronization.37
Synchronization.37myrajendra
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJavabynataraJ
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Javaparag
 
Multithread Programing in Java
Multithread Programing in JavaMultithread Programing in Java
Multithread Programing in JavaM. Raihan
 

What's hot (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
 

Similar to Jython-Introduction

python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questionsgokul174578
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
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 MalothBhavsingh Maloth
 
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 EnvironmentPython Devloper
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experiencedzynofustechnology
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming LanguageMansiSuthar3
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask TrainingJanBask Training
 
4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptx4_Introduction to Python Programming.pptx
4_Introduction to Python Programming.pptxGnanesh12
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 

Similar to Jython-Introduction (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
 

Recently uploaded

Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...ThinkInnovation
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 

Recently uploaded (20)

Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 

Jython-Introduction

  • 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.