SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group
USA

December 2001


REXX and Python Side-by-Side

by Sheridan George


With REXX available for free to OS/2 users one would wonder why look at another interpreted programming language for use on OS/2.  Now that you are waiting for me to convince you to abandon REXX I'm not going to do it.  I happen to like REXX and I like Python.  They both do about the same job.  There are some things REXX can do that Python can't and some things Python can do that REXX can't.

In this monograph REXX means classic REXX.  I have no experience whatsoever with Object REXX.  Which means I will not be dwelling on the fact that Python is object oriented.  That part of the comparison will be for an other day.  Also, I will not delve into the history of either language.  I'm simply going to compare several abilities of each language.

I got involved with Python while teaching computer programming at Heritage Christian High School.  I had an OS/2 lab there but I knew most students would be out in the windoze world and probably would not have access to REXX.  Python was a good substitute.  It is as easy to learn as REXX, very powerful, and is freely available to Unix, Linux, and Windows users.  The version of Python I have installed is Python/2 version 1.5.2 for OS/2 from: http://warped.cswnet.com/~jrush/python_os2/index.html

The other important url is: www.python.org

Let's see how the two languages compare.
 
REXX
Python
Programming Environment
  • Text editor
  • Programs called from the command line
  • REXXTry for a real time environment
  • Text editor
  • Programs called from the command line
  • Running Python.exe results in an environment similar to REXXTry
Assignment
  • VarName = 27
  • VarName = "aString"


Set x equal to y and increment y:

x = y
y = y + 1

  • VarName = 27
  • VarName = "aString"


Set x equal to y and increment y:

x , y = y,  y + 1

Style
  • Indenting unimportant
  • Blocking: do ... end
Control
  • if ... then ... else
  • select ... when
Loops
  • do <number>
  • do while ... end
  • do until ... end
String Functions
  • translate("string") returns
    • STRING
  • translate(string,tableIN,tableOUT)
    • translate looks for each symbol in string in tableIN and replaces it with the symbol in tableOUT that is in the corresponding position of the string symbol in tableIN.
  • substr(string,start,number)
    • substr() is a symbol by symbol slicer.  It returns number of symbols starting at the symbol at start.
  • word(string, number)
    • word() returns the number of symbol groups (whole words) delimited by a space.
  • uppercase(string)
  • lowercase(string)
  • swapcase(String)
    • returns: sTRING
  • Python's substring operations
    • Python's symbol slicer {string[s,e]} starts at position s+1 of string and ends at position e-1.
Data
Structures
  • Lists
    • x = "1 2 4 9 3 6 4"
    • operations on lists
      • word(x,#) returns the word at position # but does not remove it
      • pos(string, x) returns the starting position of string in x
      • parse var x ele1 ele2 .
      • reverse(x)
  • Lists
    • x = [1,2,4,9,3,6,4]
    • operations on lists:
      • sort
      • reverse - reverses the order
      • remove - an element
      • pop - removes last element
      • append - to the list
      • index - returns the position at which an element is found
      • extend - adds another list to this list
      • insert - add an element at a specific place
      • count - counts the number of times an object occurs in the list

Note: some new emx-compiled Python executables and add-on libraries have recently been uploaded to Hobbes by Andrew MacIntyre. For now you'll find them on Hobbes in the incoming section.


The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.