Python is a scripting language that is well suited for automation, utilities, and small applications. Python is not a good candidate for large applications due to performance constraints. Python can usually always replace Rexx scripts and sometimes even JCL. Benefits of python on z/OS as opposed to Rexx are numerous, such as Python being platform agnostic, having a large pool of workers skilled in it, being zIIP eligible between 70-98% of the time, and having access to modern conveniences and functions not present in Rexx or JCL. Python being zIIP eligible can lead to cost savings if Python is used in many utilities and applications, or performance improvements if the system is taxed but zIIP is available. The rest of this tutorial will go over some basic facts about python you need to know and then following entries will cover how you get things done on z/OS using Python.
Python ships with z/OS 3.1 but can be manually installed all the way down to z/OS 2.4. It can be installed with minimal sysprog experience as well.
Once you have installed Python you can run it by typing python3 in an SSH session or through OMVS, OpenSSH is greatly preferred as you can have more sessions open and test your code through a VS Code terminal later on. An interactive session will start and you can type in print("Hello World!") to test it out. This is vaguely similar to REXXTRY if you don't supply python3 a command.
>>> print("Hello World!")
Hello World!
>>>
type exit() to exit it
>>>exit()
The easiest way to develop Python on z/OS is through Visual Studio Code and the Zowe Explorer plugin. Zowe Explorer is a plugin that allows you to interact with z/OS Unix and datasets, as well as submit jobs. Another plugin you should consider picking up if you go the VS Code route is Ruff, it checks your code quality to some extent. An alternative to VS Code also exists, if your employer has a license for PyCharm you can do development through that in a similar and modern fashion, as Zowe Explorer also has a plugin for that IDE.
Another thing you should familiarize yourself with when working with Python is the concept of packages. You can install packages that allows you to do things more easily, such as IBM's ZOAU that allows you to access datasets and traditional z/OS functions through python scripts. If you find yourself re-using code often you can even make your own packages rather than duplicating code.
Python comes with a variety of built in packages, this is referred to as the Python standard library. There's a lot of useful functions in here and this is really where Python starts to show it advantages over Rexx and JCL. We will cover some of the popular python standard library packages like tomllib and argparase later on in this tutorial series.