Package prompt :: Module interpreter :: Class Interpreter
[hide private]
[frames] | no frames]

Class Interpreter

source code

Instance Methods [hide private]
 
__init__(self, show_script=True, raise_relax_error=False)
The interpreter class.
source code
 
_execute_uf(self, *args, **kargs)
Private method for executing the given user function.
source code
dict
_setup(self)
Set up all the interpreter objects.
source code
 
off(self, verbose=True)
Turn the user function introductions off.
source code
 
on(self, verbose=True)
Turn the user function introductions on.
source code
 
populate_self(self)
Place all special objects into self.
source code
 
prompt_colour_off(self)
Turn the prompt colouring ANSI escape sequences off.
source code
 
prompt_colour_on(self)
Turn the prompt colouring ANSI escape sequences off.
source code
 
run(self, script_file=None)
Run the python interpreter.
source code
Method Details [hide private]

__init__(self, show_script=True, raise_relax_error=False)
(Constructor)

source code 

The interpreter class.

Parameters:
  • show_script (bool) - If true, the relax will print the script contents prior to executing the script.
  • raise_relax_error (bool) - If false, the default, then relax will print a nice error message to STDERR, without a traceback, when a RelaxError occurs. This is to make things nicer for the user.

_execute_uf(self, *args, **kargs)

source code 

Private method for executing the given user function.

Parameters:
  • uf_name (str) - The name of the user function.

_setup(self)

source code 

Set up all the interpreter objects.

All objects are initialised and placed in a dictionary. These will be later placed in different namespaces such as the run() method local namespace. All the user functions and classes will be auto-generated.

Returns: dict
The dictionary of interpreter objects.

run(self, script_file=None)

source code 

Run the python interpreter.

The namespace of this function is the namespace seen inside the interpreter. All user accessible functions, classes, etc, should be placed in this namespace.

Parameters:
  • script_file (None or str) - The script file to be executed. For the interpreter mode, this should be left as None.