File: python_shell.rst

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (40 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
The Python Shell
================================================================================
.. currentmodule:: ost.gui

.. class:: PythonShell

OpenStructure has a powerful Python Shell which has some handy features. It is 
completely integrated into OpenStructure and allows you enter Python code. 

Multi line detection
--------------------------------------------------------------------------------
The Python Shell detects automatically if a code block is complete or not. 
For example a simple print statement in the command line is a complete code 
block. Therefore the code will be executed after pressing enter:
 
.. image:: images/100210_single_line.png

When a multiline codeblock (like a for loop or an if instruction) is being 
entered in the command line, the code is not executed until the code block is 
complete:

.. image:: images/100210_multi_line.png
 
When a code block is not complete, pressing enter appends an empty line at the 
end of the code block. To execute such a code block, you simply have to press 
enter twice. 

Auto completion
--------------------------------------------------------------------------------
After pressing tab in the Python Shell, it returns you possible extensions 
to your entered text. This feature can be used for completing variable names 
or functions:
  
.. image:: images/100210_auto_completion.png
 
It is also possible to complete a file system path string. By pressing tab while
editing a string, the shell displays all file or folders of the given 
directory: 
 
.. image:: images/100210_path_completion.png