================================================================================ = = = = = Welcome to the world of Python = = = = = ================================================================================ ================= Introduction : ================= Thank you for trying out Python. It has been ported to the IIgs in the hope that someone can use it. I was always frustrated with there being no "for" or "while" loops or variables in the GNO/ME shell/kernel. Python is this and MUCH, much more. With all the documentation written, I will not even attempt to explain Python. This file only explains the IIgs add ons for Python. Python, unless you want it to be (there is no system command functionality if gsh is not running), is not a replacement for gsh! Please, at least go through some sections of the tutorial before being a critic. ================= Installation : ================= Just run "install" in this directory. The install script runs Python and Python will install itself. It will prompt you to see if you want the Python script library installed. Anyone who wants to imbed Python in C then please get in touch with me for the libraries. I did not include them because of their size. I may post them separatly. ./install ================= Usage for Python: ================= python [-d] [-i] [-s] [-u ] [-v] [-V] [-R] [-c cmd | file | -] [arg] ... Options and arguments (and corresponding environment variables): -d : debug output from parser (also PYTHONDEBUG=x) -i : inspect interactively after running script (also PYTHONINSPECT=x) -s : suppress printing of top level expressions (also PYTHONSUPPRESS=x) -u : unbuffered stdout and stderr (also PYTHONUNBUFFERED=x) -v : verbose (trace import statements) (also PYTHONVERBOSE=x) -I : Turn off autoindentation (IIgs only) -R : Turn off readline (IIgs only) -V : version information (IIgs only) -c cmd : program passed in as string (terminates option list) file : program read from script file - : program read from stdin (default; interactive mode if a tty) arg ...: arguments passed to program in sys.argv[1:] Other environment variables: PYTHONSTARTUP: file executed on interactive startup (no default) PYTHONPATH : colon-separated list of directories prefixed to the default module search path. The result is sys.path. ================= Readline : ================= ReadLine is in the IIgs Toolbox in the Text Tool Set (pg 23-30). It, readline, is also a library distribution from Gnu. While both could have been used, neither were. The readline in the IIgs implementation was created by me for two reasons. When using the ReadLine, Text Tool set call (notice the uppercase R and uppercase L :-)), I noticed it wasn't very portable. I then ported the GNU readline (I will try to post this as well so nobody needs to duplicate the effort) and found that it created > 200K and forced me to compile Python in large memory model. The large memory model of Python died a horrendous death. Maybe in the future with a future Orca/C compiler, I will try again. For the IIgs Python I created a set of input routines using the ioctl calls in GNO/ME. For that reason I needed to choose between the down arrow working or the return key working. After trying and trying to get both to work with ioctl calls, I have finally given up. If anyone knows how to do this, then please tell me and I will try to get it into any future release. Python generally does not have command line editing. Not unless the GNU readline library has been ported along with it. Keys that work: Up arrow - Not really suggested since the down arrow key doesn't work and you may be tempted (I know I do) to use the down arrow key. The up arrow key goes to the previous history line. Control p - Goes to the previous history line. (Same as the up arrow.) Control n - Goes to the next history line. (What the down arrow should do.) Right arrow - Moves one character to the right. Control f - Moves one character to the right. Left arrow - Moves one character to the left. Control b - Moves one character to the left. Back Space - Deletes the previous character to the left. Control a - Moves cursor to the beginning of the line. Control e - Moves the cursor to the end of the line. Ignore the following: (The documentation for Python says that they should work but, in the IIgs version they don't. Maybe in future releases.) Control k Control _ Control y Control d ================= Auto Indentation: ================= When porting Python, when pushing the tab key, the only response I got was a ^I. This was not acceptable to me. I wanted a number of spaces to appear. When making the input routines, I made indentation work. I also noticed the author of Python saying (in the documentation Python Tutorial Page 7 Section 2.3.4): "...... however, some wishes are left: It would be nice if the proper indentation were suggested on continuation lines......." I tried the 'suggestion of indentation' but that, in my opinion and my opinion only, did work right. I use 'auto indentation' which means that if an indentation was given previously, a tab will be put in for each previous indentation given. I think it works much nicer. If you don't then tell me. Maybe I will change it.:-) ================= Readline Module : ================= I know you probably haven't even read the tutorial yet but.... The following is what you would get when getting the __doc__ for the module and each command in the module. Apple IIgs readline module. (uses GNU history library only) off - turn readline off (default on). on - turn readline on (default on). indentoff - turn automatic indentation off (default on). indenton - turn automatic indentation on (default on). editmode - switch between insert and overstrike.(default insert). tabsize - make the tabsize a certian size(default 8). list - list history and return a list object of entries. read - read history from ~/.history file. save - save in memory history to ~/.history file. truncate - truncate history (~/.history) file to lines given. stifle - stifle history in memory to size given. unstifle - unstifle history in memory. Some more explanations: (All commands require the import readline to have been performed previously.) You can turn off the readline support. Using readline.off() will turn off the readline. It also turns off auto indentation. The command line options can also be used. Does nothing if already on. If readline has been turned off, then a readline.on() will turn it back on. Python on other systems does not have auto indentation. To make it so that it works like other systems, the command line option can be used or use readline.indentoff(). The command readline.indenton() will turn back on the auto indentation that is, at this point, only on the IIgs. The default mode of entry is insert mode. A readline.editmode(1) turns on overstrike mode while readline.editmode(0) turns on insert mode command line editing. This command returns what the old value was. The display tab size in spaces can be changed using the command readline.tabsize(value). Value is how many spaces make up a tab while command line editing. The default tab size is 8. This command returns the old number of spaces to a tab. To get a list object that has everything in the history list, do the command readline.list(). If the ~/.history file then the command readline.read() will put any commands into the history list after the present position. The ~/.history file will be truncated to zero if it exists or just created if not there. Then the command readline.save() will put all items in the history into the ~/.history file. You can truncate the ~/.history to a certain number of command lines with the command readline.truncate(value). The value is the number of lines at the end of the file to keep. Normally all history is remembered. readline.stifle(value) is used to cut down the number of lines remembered to value. Opposite of stifle. readline.unstifle() returns < 0 the history list was stifled before this command. The returned value is >= 0 if stifling was not in effect before the readline.unstifle() command. ================= History : ================= The GNU readline and history libraries were ported so that they could be used with Python on the IIgs. While the readline library was too big with all of its arrays and structures and such to include with the IIgs port the history library was small and could be used. Some history expansions that can be used are (taken from the history source): !! the previous command !n command line N !-n current command-line minus N !str the most recent command starting with STR !?str[?] the most recent command containing STR ================= THANKS! : ================= Thanks need to be given to Devin Reade for his environ library Jawaid Bazyar for his help; and Jawaid Bazyar and Tim Meekins for making a great kernel/ programming environment for the IIgs. Many thanks also go to Mike Westerfield for his wonderful C compiler/libraries. (Many, many, many thanks to my wife for being very, very, very patient. [Hey she proofed this:-)]) ================= LEGAL STUFF : ================= The ORCA/C run-time libraries are Copyright 1987-1995 Byte Works, Inc. and distributed with permission. The GNO Multitasking Environment is Copyright 1991-1995 by Procyon Enterprises Incorporated. Python Copyright (c) 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. Readline is Copyright (C) 1989, 1991 by the Free Software Foundation, Inc. -- Gary F. Desrochers April, 1996 g.desrochers@genie.geis.com