Tips for Using Nengo's Python Scripting Interface
General
The scripting language is Python. General Python documentation is available here.
Press CTRL-P (for “Python”) at any time, to change focus to the command entry field.
Available Classes
Any Java class in the Nengo API can be imported. Web-based documentation for the API is available here.
A number of variables are created for you within the Python interpreter. These are: 1) "world", which you can use to display in the GUI any nodes that you create through scripting; 2) "that", which provides access to the currently-selected item in the GUI; 3) any networks that you have open at the top level of the GUI. The variable names are just the network names, although they may be modified slightly to conform to Python variable naming rules.
You can view a list of available variables by entering the command “print dir()”.
Running a Script from a File
You can run a script by entering "run script.py" (replace "script.py" with the name of your script, including the relative path from the install directory).
Command History
You can move through a list of previously-entered commands using the up and down arrows. For example entering "print dir()", then pressing ENTER, then UP-ARROW, then ENTER again will print your available variables twice.
Code Completion
Variables, classes, constructors, and methods can be auto-completed. Auto-completion for methods is engaged when you type a dot (".") after a variable or class name. You can also engage auto-completion based on a partial variable/method/class name by pressing TAB after typing part of the name. Finally, you can engage auto-completion for constructor arguments by pressing TAB after typing a class name followed by "(". Once auto-completion is engaged, you can move through completion options with up and down-arrow keys. To leave auto-completion mode, press ESCAPE.
Viewing API Documentation
While in auto-completion mode, hold down CTRL to display documentation for the currently-selected option, if available. The documentation is displayed as a tool-tip. Press CTRL twice rapidly to display the documentation in the console window instead (this may be useful in the rare event that there is so much documentation that it cannot all be displayed on the screen at once). You can also get documentation (if available) for Java classes, whether or not they have been imported into the Python interpreter, by entering "help classname" (replace classname with the fully-qualified name of the class, e.g. "help ca.nengo.model.Network").