z/OS Tools & Language

Expand all | Collapse all

Calling z/OS services in python

  • 1.  Calling z/OS services in python

    Posted 05-01-2018 02:42

    I was thinking about how convenient it would be if I could call z/OS system services, e.g. IEFSSREQ, from within a python program. I’ve been thinking about it and doing a little research, and I think it would be possible to do this… But I was hoping I could get some advice from Rocket or other users of this forum before I proceed any further.

    Here’s the approach I was thinking of taking…

    1. CPython (which I believe the Rocket version of python is a port of) can be extended with “extension modules” that are written in C. I was going to use this documentation for guidance:

    2. Next, the z/OS XL C compiler supports a #pragma that can be used for interlanguage function calls. As a part of this, I would have to create a “stub routine” which would be the glue between the C program and the z/OS service in question. Documentation about the pragma on this page:

    I’d appreciate any feedback or suggestions about this approach before I invest a lot of time into it. Or maybe there’s an easier way that I am not thinking of.

  • 2.  RE: Calling z/OS services in python

    Posted 05-02-2018 06:20

    Another alternative which avoids writing Python extension modules, could be the built-in foreign function library: the ‘ctypes’ module.

    It allows to load external DLLs (load modules) and define parameters to be used for the call to its entry points. But to use it for z/OS system services it depends on whether there is a system DLL that provides the functionality.

    It would be good to have more z/OS specific functionality available for Python including record I/O…


  • 3.  RE: Calling z/OS services in python

    Posted 05-04-2018 04:17

    This is admittedly not exactly what you’re asking, but you may find this interesting:



  • 4.  RE: Calling z/OS services in python

    Posted 12-05-2018 16:06

    Does anyone know whether MVS cmds issued using Python code like REXX? This is in reference to “Python for z/OS” V3.6.

  • 5.  RE: Calling z/OS services in python

    Posted 01-09-2020 18:39

    Thought I would share a useful link that an IBMer wrote about creating python extensions on z/OS: https://medium.com/@kalebporter/writing-python-3-extensions-in-c-c-with-z-os-support-d057af3b90ba

    I am successfully using the IBM xlc compiler’s embedded assembly support to call z/OS services in the python extension module.