Database Reference
In-Depth Information
Chapter 6
Advanced Scripting
Much of the power of a command-line interface like EM CLI is the ability to automate the execution of multiple
commands at a time. This chapter dives deep into the marriage of Python and EM CLI in what is known as interactive
and scripting mode.
The first part of the chapter reviews some of the history of where Python, Jython, and JSON came from. Being
able to take advantage of Python functionality in EM CLI requires a basic understanding of programming and Python
syntax. An introduction to Python in this chapter, including examples, will allow even the first-time Python user to
tackle Python efficiently in EM CLI.
Finally, a detailed example will feature the use of a Python class object to take advantage of EM CLI functionality
to modify the properties of multiple targets at a time. This is a common task that is tedious in the graphical user
interface and is necessary to understand and use in EM CLI.
History of Python
Python was created in the late 1980s by Guido van Rossum and originated from an interpreted language called ABC.
At the time, van Rossum was working with ABC and liked the syntax but wanted to change some of the functionality.
During the Christmas holidays of 1989, van Rossum designed the language that would later be called Python. Python
was officially released in 1991 while van Rossum worked for a company called Stichting Mathematisch Centrum in
Amsterdam.
Python did not get its name from the dangerous reptile, but rather from the popular British BBC comedy series,
Monty Python's Flying Circus . Van Rossum was a fan of the show and needed a name that was fitting for the language.
Van Rossum continues to have a central role and has been named Python's Benevolent Dictator for Life (BDFL).
This term was coined for van Rossum but has become a common description for open-source software that has
retained its creator as the final decision maker for disputes or arguments within the community.
Python is a programming language, but because the code is compiled at runtime, it can also be considered a
scripting language. There is not always a clear delineation between the two, and the definition of each has changed
over time. Generally, programming languages must be compiled before they can be run and scripts are run from a set
of commands, either interactively or from a file. Since Python can do either and both at the same time, the answer to
the question “Is Python a programming or a scripting language?” is “Yes!”
Jython
Jython is an implementation of Python written in Java. Jython was initially created in late 1997 to replace the “C”
implementation of Python with Java for performance-intensive code accessed by Python programs. Knowing how
to code in Java, while beneficial to working with Jython, is not a prerequisite. In fact, one can use Jython with no
knowledge of Java whatsoever. However, when using Jython it is likely one will come across Java code, as Jython
programs use Java classes in addition to Python modules.
 
Search WWH ::




Custom Search