I am looking for code samples of how to work with MVS datasets and members and other z/OS specific tasks that have been already accomplished with Python.
I hope it will help: https://pypi.python.org/pypi/PyZOS
With 2.7.12 Beta2 from Nov 2016 the following script reads a member in a PDS and prints it.
Different to the earlier 2.7.6 release internal Python strings are in ASCII/Latin1 encoding so conversion needs to be done.
It will be interesting to see if in a future release some automatic conversion will be done for text files, especially if they have encoding tags set on the file system.
with open('//MM.JCL(TEST)','r') as f: # open file in text/record mode
stream = codecs.getreader('cp1047_oe')(f) # convert data from EBCDIC to Latin1
for line in stream:
print line[:-1] # print line w/o last character (=new line)
Please see also the discussion in Python sample code files