SlideShare una empresa de Scribd logo
1 de 15
09/26/16 For a Better Future 1
Python Introduction
An Examination of Python for
CHX?
09/26/16 For a Better Future 2
Introduction
 To have a better understanding of
Python role at CHX.
 By Kai Liu, Systems Analyst at
Chicago Stock Exchange.
09/26/16 For a Better Future 3
Topics of Discussion
 What is Python?
 Why Python?
 Perl vs. Python?
 What we need for Python?
 What is CHX structure for Python?
 Work Example.
 Summary
09/26/16 For a Better Future 4
What is Python?
 Python is an interpreted, object-
oriented, high-level programming
language with dynamic semantics. Its
high-level built in data structures,
combined with dynamic typing and
dynamic binding, make it very
attractive for Rapid Application
Development, as well as for use as a
scripting or glue language to connect
existing components together.
Why Python?
 Python's simple, easy to learn syntax
emphasizes readability and therefore reduces the
cost of program maintenance. Python supports
modules and packages, which encourages
program modularity and code reuse. The Python
interpreter and the extensive standard library are
available in source or binary form without charge
for all major platforms, and can be freely
distributed
09/26/16 For a Better Future 5
09/26/16 For a Better Future 6
Perl vs. Python?
 Python and Perl come from a similar background
(Unix scripting, which both have long outgrown),
and support many similar features, but have a
different philosophy. Perl emphasizes support for
common application-oriented tasks, e.g. by having
built-in regular expressions, file scanning and report
generating features. Python emphasizes support for
common programming methodologies such as data
structure design and object-oriented programming,
and encourages programmers to write readable
(and thus maintainable) code by providing an
elegant but not overly cryptic notation.
What we need for Python?
 Python 2.7.8 vs. 3.5+
http://www.activestate.com/activepython/downloa
ds
 PyCharm IDE 2016.1+
 https://www.jetbrains.com/pycharm/download/
 Support for most platforms
 cx_Oracle is a Python extension module that
enables querying and updating of Oracle
databases using a database API 2.0 that is
common to all database access modules. A
number of extensions to the common database
API have also been included in order to take
advantage of some of the features available
exclusively to Oracle. Download at:
https://pypi.python.org/pypi/cx_Oracle/
09/26/16 For a Better Future 7
09/26/16 For a Better Future 8
What is CHX structure for
Python?
• Build components to support template for future scripts:
• Import Modules and Class
Load loadControlParameters() – Get parameters
Load Oracle() Class – Get Oracle Connection
Load GTT_init()– Populate GTT tables
Load Jobs() – Start and End Jobs
Load Get_token_list() – Build Token List
Load Call_System – System Host calls
Load SendEmails() – Send Email out.
Load Exec_Proc() – Run PL/SQL procedure
Load Exec_Refcursor() – Return Refcursor Results
Why do we want to use modules
and Class to build program?
 We want to modularize in our code for reuse and
many other benefits.
 Modules to provide plumbing for basic operation
needed in most of our batch programs.
 Easier to formulate a template for building our
wrapper scripts for our scheduler.
 It also can be use to help rapid prototyping for
development of new program to do task for
specific operation.
 Provide an environment to promote new modules
and a community to be share in other programs.
09/26/16 For a Better Future 9
09/26/16 For a Better Future 10
Work Example
 I had a project that had business requirements to
extracted Attachments from database with Perl.
 The process needed to extract on database
attachments based on a file list provided be user
on which cases were needed for attachments to
be extracted. Originally it was written in Perl. I’ve
rewrote using the Python to provide same
functionality using a new Python Template that
I’ve been developing.
 The codes snipped below is to simplified to help
illustrate the contents of the discussion of using
the Python.
Work Example Cont.
 Real Example:
 The code snipped below for the framework of the body:
loadControlParameters(params) -- Get Parameters
if __name__ == "__main__":
main(sys.argv[1:]) -- Get arguments
db = Oracle() -- Established Oracle connection
…
p_SQL = """WITH
aPerson AS … “ -- Contains Sql Query
09/26/16 For a Better Future 11
Work Example Cont.
# Fetch the attachment with proc passed and case list passed.
prc_tab = db.exec_proc(prc_str,list) -- Execute PL/SQL block
case = db.query(p_SQL) -- Execute the Sql Query
# Get and create notes based on Case List.
for Notes in case: -- Loop to get all notes.
-- write files.
09/26/16 For a Better Future 12
Work Example Cont.
 The end result was files extracted out of
the Oracle database. With modules
currently built an developing new
modules for other functions we can quick
have a library of reusable modules to
allow more productivity in programming
for a rapid development for programs to
be at production level quality based on
proven modules that have mature.
09/26/16 For a Better Future 13
09/26/16 For a Better Future 14
Summary?
 The summary is that Python should be consider for future
programs. It’s not here to replace the Perl scripts, but be
consider a future programming language to be productive with
an be maintainable and scalability. There a lots of information
on Python and what it can do. Also, I believe it’s an easy
language to adapt and use for developers coming for Java, Ruby
and C++.
 Python that everyone will notice: the fact that whitespace
(indentation) is actually significant in the language syntax. The
language has no analog of the C and Perl brace syntax; instead,
changes in indentation delimit statement groups.
09/26/16 For a Better Future 15
Thank You
 Q&A?

Más contenido relacionado

Destacado (6)

Sql Question #5
Sql Question #5Sql Question #5
Sql Question #5
 
What is Listagg?
What is Listagg?What is Listagg?
What is Listagg?
 
SQL Tuning Overview
SQL Tuning OverviewSQL Tuning Overview
SQL Tuning Overview
 
Sql Question #3
Sql Question #3Sql Question #3
Sql Question #3
 
Oracle10g External Tables
Oracle10g External TablesOracle10g External Tables
Oracle10g External Tables
 
PL/SQL11g Question #1
PL/SQL11g Question #1PL/SQL11g Question #1
PL/SQL11g Question #1
 

Similar a CHX PYTHON INTRO

Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
Laxman Puri
 

Similar a CHX PYTHON INTRO (20)

Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Researh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-pythonResearh toolbox-data-analysis-with-python
Researh toolbox-data-analysis-with-python
 
Researh toolbox - Data analysis with python
Researh toolbox  - Data analysis with pythonResearh toolbox  - Data analysis with python
Researh toolbox - Data analysis with python
 
Migration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMigration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent Decision
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
CSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and JythonCSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and Jython
 
CTE 323 - Lecture 1.pptx
CTE 323 - Lecture 1.pptxCTE 323 - Lecture 1.pptx
CTE 323 - Lecture 1.pptx
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdf
 
Ways To Become A Good Python Developer
Ways To Become A Good Python DeveloperWays To Become A Good Python Developer
Ways To Become A Good Python Developer
 
Rapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute BeginnersRapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute Beginners
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
Возможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OSВозможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OS
 
Python
PythonPython
Python
 
Seminar report on python 3 course
Seminar report on python 3 courseSeminar report on python 3 course
Seminar report on python 3 course
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdf
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes
 

Más de Kai Liu (15)

QQ and Advance query
QQ and Advance queryQQ and Advance query
QQ and Advance query
 
Schedulers
SchedulersSchedulers
Schedulers
 
PL/SQL Example for IF .. ELSIF
PL/SQL Example for IF .. ELSIFPL/SQL Example for IF .. ELSIF
PL/SQL Example for IF .. ELSIF
 
Dms 2.0 Direction
Dms 2.0 DirectionDms 2.0 Direction
Dms 2.0 Direction
 
Dms 2.0 Plan Proposal
Dms 2.0 Plan ProposalDms 2.0 Plan Proposal
Dms 2.0 Plan Proposal
 
Toad
ToadToad
Toad
 
Dms Emailing Reports
Dms Emailing ReportsDms Emailing Reports
Dms Emailing Reports
 
QQ And Advance Query
QQ And Advance QueryQQ And Advance Query
QQ And Advance Query
 
Troubleshooting Batch Reports
Troubleshooting Batch ReportsTroubleshooting Batch Reports
Troubleshooting Batch Reports
 
Dms Reporting Criteria
Dms Reporting CriteriaDms Reporting Criteria
Dms Reporting Criteria
 
Dms Batch Reporting
Dms Batch ReportingDms Batch Reporting
Dms Batch Reporting
 
Dms Reporting Overview
Dms Reporting OverviewDms Reporting Overview
Dms Reporting Overview
 
Dms 2 Direction
Dms 2 DirectionDms 2 Direction
Dms 2 Direction
 
Dms Project
Dms ProjectDms Project
Dms Project
 
Dms Acknowledgements
Dms AcknowledgementsDms Acknowledgements
Dms Acknowledgements
 

CHX PYTHON INTRO

  • 1. 09/26/16 For a Better Future 1 Python Introduction An Examination of Python for CHX?
  • 2. 09/26/16 For a Better Future 2 Introduction  To have a better understanding of Python role at CHX.  By Kai Liu, Systems Analyst at Chicago Stock Exchange.
  • 3. 09/26/16 For a Better Future 3 Topics of Discussion  What is Python?  Why Python?  Perl vs. Python?  What we need for Python?  What is CHX structure for Python?  Work Example.  Summary
  • 4. 09/26/16 For a Better Future 4 What is Python?  Python is an interpreted, object- oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.
  • 5. Why Python?  Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed 09/26/16 For a Better Future 5
  • 6. 09/26/16 For a Better Future 6 Perl vs. Python?  Python and Perl come from a similar background (Unix scripting, which both have long outgrown), and support many similar features, but have a different philosophy. Perl emphasizes support for common application-oriented tasks, e.g. by having built-in regular expressions, file scanning and report generating features. Python emphasizes support for common programming methodologies such as data structure design and object-oriented programming, and encourages programmers to write readable (and thus maintainable) code by providing an elegant but not overly cryptic notation.
  • 7. What we need for Python?  Python 2.7.8 vs. 3.5+ http://www.activestate.com/activepython/downloa ds  PyCharm IDE 2016.1+  https://www.jetbrains.com/pycharm/download/  Support for most platforms  cx_Oracle is a Python extension module that enables querying and updating of Oracle databases using a database API 2.0 that is common to all database access modules. A number of extensions to the common database API have also been included in order to take advantage of some of the features available exclusively to Oracle. Download at: https://pypi.python.org/pypi/cx_Oracle/ 09/26/16 For a Better Future 7
  • 8. 09/26/16 For a Better Future 8 What is CHX structure for Python? • Build components to support template for future scripts: • Import Modules and Class Load loadControlParameters() – Get parameters Load Oracle() Class – Get Oracle Connection Load GTT_init()– Populate GTT tables Load Jobs() – Start and End Jobs Load Get_token_list() – Build Token List Load Call_System – System Host calls Load SendEmails() – Send Email out. Load Exec_Proc() – Run PL/SQL procedure Load Exec_Refcursor() – Return Refcursor Results
  • 9. Why do we want to use modules and Class to build program?  We want to modularize in our code for reuse and many other benefits.  Modules to provide plumbing for basic operation needed in most of our batch programs.  Easier to formulate a template for building our wrapper scripts for our scheduler.  It also can be use to help rapid prototyping for development of new program to do task for specific operation.  Provide an environment to promote new modules and a community to be share in other programs. 09/26/16 For a Better Future 9
  • 10. 09/26/16 For a Better Future 10 Work Example  I had a project that had business requirements to extracted Attachments from database with Perl.  The process needed to extract on database attachments based on a file list provided be user on which cases were needed for attachments to be extracted. Originally it was written in Perl. I’ve rewrote using the Python to provide same functionality using a new Python Template that I’ve been developing.  The codes snipped below is to simplified to help illustrate the contents of the discussion of using the Python.
  • 11. Work Example Cont.  Real Example:  The code snipped below for the framework of the body: loadControlParameters(params) -- Get Parameters if __name__ == "__main__": main(sys.argv[1:]) -- Get arguments db = Oracle() -- Established Oracle connection … p_SQL = """WITH aPerson AS … “ -- Contains Sql Query 09/26/16 For a Better Future 11
  • 12. Work Example Cont. # Fetch the attachment with proc passed and case list passed. prc_tab = db.exec_proc(prc_str,list) -- Execute PL/SQL block case = db.query(p_SQL) -- Execute the Sql Query # Get and create notes based on Case List. for Notes in case: -- Loop to get all notes. -- write files. 09/26/16 For a Better Future 12
  • 13. Work Example Cont.  The end result was files extracted out of the Oracle database. With modules currently built an developing new modules for other functions we can quick have a library of reusable modules to allow more productivity in programming for a rapid development for programs to be at production level quality based on proven modules that have mature. 09/26/16 For a Better Future 13
  • 14. 09/26/16 For a Better Future 14 Summary?  The summary is that Python should be consider for future programs. It’s not here to replace the Perl scripts, but be consider a future programming language to be productive with an be maintainable and scalability. There a lots of information on Python and what it can do. Also, I believe it’s an easy language to adapt and use for developers coming for Java, Ruby and C++.  Python that everyone will notice: the fact that whitespace (indentation) is actually significant in the language syntax. The language has no analog of the C and Perl brace syntax; instead, changes in indentation delimit statement groups.
  • 15. 09/26/16 For a Better Future 15 Thank You  Q&A?