Python

Python

Python

 View Only
  • 1.  spss.submit() will affect preceding print() of unicode characters

    Posted Fri January 07, 2022 03:03 AM
      |   view attached
    Dear all,

    I have encountered a puzzling effect of spss.submit() on the output of print().

    In PROGRAM blocks containing a spss.submit() statement, unicode characters printed with print() will appear in the output as unicode codepoints. This is true even if the print() statement precedes the spss.submit statement. In preceding and following PROGRAM blocks without spss.submit() statements, the unicode characters are printed correctly.

    Is there an explanation or a workaround for this?

    * Encoding: UTF-8.
    BEGIN PROGRAM PYTHON3.
    #coding=utf-8
    import spss, spssaux
    print ('these statements will print fine:')
    print ('├')
    print('•')
    END PROGRAM.
    
    BEGIN PROGRAM PYTHON3.
    #coding=utf-8
    import spss, spssaux
    print ('these statements will print unicode codepoints :')
    print ('├')
    print('•')
    
    # The next statement requires a dataset with at least one variable in it;
    # if there is no such dataset, the statement will produce an error;
    # But either way: The mere presence of the spss.submit () statement 
    # will affect the output of the preceding (!) print() statements
    
    spss.Submit ('COMPUTE newVar = 1.')
    END PROGRAM.
    
    BEGIN PROGRAM PYTHON3.
    #coding=utf-8
    import spss, spssaux
    print ('\nthese statements will print fine again:')
    print ('├')
    print('•')
    END PROGRAM.
    
    ​


    Best regards
    Frank Watzl


  • 2.  RE: spss.submit() will affect preceding print() of unicode characters

    Posted Fri January 07, 2022 09:44 AM
    Hi Frank,

    I'd like to confirm first that IBM Open Enterprise SDK for Python is being used. Could you run the following Python code and provide the output?

    import platform
    print(platform.sys.version)​


    Thanks,

    Steven

    ------------------------------
    Steven Pitman
    ------------------------------



  • 3.  RE: spss.submit() will affect preceding print() of unicode characters

    Posted Fri January 07, 2022 12:34 PM
    Hi Steven,

    running the code in a BEGIN PROGRAM PYTHON3 Block I get

    3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
    [Clang 6.0 (clang-600.0.57)]

    Does this help?

    ------------------------------
    Frank Watzl
    ------------------------------



  • 4.  RE: spss.submit() will affect preceding print() of unicode characters

    Posted Fri January 07, 2022 02:10 PM
    Hi Frank,

    This discussion is mainly for asking questions about the use of IBM Open Enterprise SDK for Python on z/OS. It doesn't look like it's being used here, so I'd recommend asking your question over at the SPSS community discussions, or contact support for better help.

    Thanks,

    Steven

    ------------------------------
    Steven Pitman
    ------------------------------



  • 5.  RE: spss.submit() will affect preceding print() of unicode characters

    Posted Fri January 07, 2022 02:33 PM
    Edited by Frank Watzl Fri January 07, 2022 02:33 PM
    Hi Steven,

    thank you for your assistance and my apologies for posting to the wrong discussion.


    ------------------------------
    Frank Watzl
    ------------------------------