Public Member Functions | |
__init__ (swipl='/usr/local/bin/swipl-q-tty', blocked=None) | |
errorp () | |
readyp () | |
force () | |
force_quit () | |
run_query_once (q) | |
run_query (q) | |
lastprompt () | |
get_bindings (s=None) | |
get_result () | |
finish () | |
_balanced (s) | |
_flushall () | |
_close_query () | |
_prep_query (q) | |
_alrmhandler (signum, frame) | |
_readtoprompt () | |
_readalt (vars) | |
_endswp (s) |
|
swipl -- the path to SWI-Prolog; it is sensible to append the arguments '-q' and '-tty' for silent output and to tell Prolog that it does not run on a terminal. In fact, please do so unless you have specific reasons for not doing so blocked -- flag specifying wether 'Error: ** here **' messages from the interpreter should be honoured; don't set to anything other than None (don't block messages) unless you specifically know your code will never be wrong! It saves processor time, but it's not really worth the risk |
|
|
|
|
|
Close a query opened with 'open_query'; note that you MUST call this method in order to avoid bad results and outright crashes! |
|
ends with prompt? |
|
|
|
|
|
|
|
|
|
Test for non-fatal error in previous Prolog query/queries |
|
Close the Prolog session; invalidates the object! This will take at least half a second, so make sure cou have the time at the point where you call it |
|
Try to get the interpreter into a sane state - works only on *NIXes for the time being (systems that provide the 'kill' command) |
|
Force quit the Prolog interpreter - works only on *NIXes for the time being (systems that provide the 'kill' command) |
|
Returns the bindings from the last query as a list of tuples (Variable, Binding) The argument is for internal use only. |
|
Returns the result of the last query (Yes or No) as a boolean value (None or not None) |
|
Returns the current prompt; normally not called by user code, but might be needed in special circumstances; return values can be one of: PROMPT_QUERY -- the normal Prolog query prompt: ?- PROMPT_ACTION -- the exception prompt PROMPT_CONTINUE -- the newline-within-unfinished-query prompt | |
|
Test for interpreter readiness - use this if you need to see if something went wrong with the last query |
|
Open a query and start generating results. Note that open_query only takes arguments that are legal arguments to call/1; you must not end the query with a full stop! This method requires the 'sets' module introduced in Python 2.3, or an equivalent module supplying the main facilities of 'sets'. Results are the same as the results from get_bindings() Use e.g. as in the following example: for result in l.run_query('( A=2 ; A=3 )'): print dict(result)['A'] |
|
Run a query as with 'once/1'; if you need more than one result, and still use this method. you'll have to run a query with - e.g. - 'findall/3' |