The Shell Window provides access to an interactive mode. This window will open as part of the main screen when you fire up the InfoPACK IDE, and packages needed to provide access to InfoPACK facilities are automatically loaded. You can type any python statement into this window; but most users will need only those facilities provided specifically by InfoPACK, and documented here. Full InfoPACK Python function specifications are given in Appendices A and B.
As with the Python direct interactive mode (using Python from a command
window), you type a Python statement into the shell window at the
prompt and then hit the Enter key to send it to the Python
interpreter.
InfoPACK scripts can be executed directly from within the shell. For example, to segment the image ``myimage.nc'' to the output file ``mysegment.nc'' with default parameter settings, you would type:
>>> run(``segment.py myimage.nc mysegment.nc'')
InfoPACK functions can similarly be called. For example, to load ``myimage.nc'' into memory, segment it, then save the result as ``mysegment.nc'' you would type:
>>> array_in = numload(``myimage.nc'') >>> array_seg = segment(array_in) >>> save(array_seg, ``mysegment.nc'')
If you ever find yourself in a situation where you seem to be hung and cannot get a new prompt, the interpreter is likely to be in a state where it is waiting for you to enter something specific (in its parse state). Hitting Ctrl-z will send a keyboard interrupt and should get you back to a prompt.
Your code is colourised as you type it in based on Python syntax types. The colour scheme may depend upon your setup; but typically comments are displayed in green, strings in purple and Python keywords in blue.
The Python scripting language uses indentation levels to define program blocks (rather than explicit begin...end syntax). The command line facilities provide limited automated support for indentation: here is an example that creates a function to produce factorials.
>>> def factorial(num):
result = 1
while num > 0:
result = result + num
num = num - 1
return result
>>>
If you type in the above example you will find that when you hit Enter after the def clause, the next line is automatically indented for you (as you enter a new block). When within a block, you will be automatically placed at the same level as the previous statement (above, this happens for the num = num - 1 statement). Each press of the Backspace key will back you out of a level of indentation (above, it needs to be used before the return statement). After a pass, return, break, continue or raise statement you will automatically backed out of a level of indentation. Hitting Enter when on the new line after ``return result'' will take you out of the function definition to a command prompt.
The IDLE IDE, provided for scripts (file/new script and file/Open script menus) provides fully automated support for indentation.
A feature that is worth knowing (because of the amount of typing it
can save you) is the command history mechanism.
Placing the cursor at the end of any line and pressing Enter will bring
a copy of all the line.
Alternatively, you can toggle through all previous commands sent to the interpreter
by using Ctrl-
(or Alt-p) and Ctrl-
(or Alt-n).
You can edit the line as desired before hitting the Enter key to have it sent to
the interpreter.
As soon as you type in the opening bracket for a function or method call a small box will pop up below the current line giving you a ``tip'' with regards to the arguments that are expected. For example, if the shell window contains:
>>> segment(
you will get a small highlighted window containing a tip on completing the statement:
segment(image, [quality=, shape=, stopping=, cooling=, looks=,
maxiters=, regionsize=, intensity=])
together with summary information on the purpose of the routine and its default parameter settings.
The window stays up until you enter the closing bracket. These tips appear for
built-in functions, any functions or methods (including class constructors)
from Python's library modules as well as for any function or methods defined
by yourself. They do not, however, occur for list, tuple or dictionary
methods.
For the functions or methods that you define, the tip will give the names of the parameters you define. The first (summary) line of the function or methods document string will also be displayed. This can be used to give information on the types of the arguments and return value.
Once an object has been defined, typing the dot (``.'') command after the object name will bring up a list of possible members or methods available. For example, if the shell window contains:
>>> image, gis = load('myfile.nc')
>>> gis.
you will get a small scrolled window containing a list of the gis class members.
InfoSAR Ltd