This is the python file helper.py
:
from collections import deque
#------DEQUE STUFF------
def create_empty():
return deque()
def append_left(deq, a):
deq = deque(deq)
deq.appendLeft(a)
return deq
and here is the prolog file:
:- module(deque, [
lib/0,
create_empty/1,
append_left/3
]).
:- use_module(library(janus)).
:- table create_empty/1, append_left/3.
lib :- py_add_lib_dir("C:/Users/vatis/OneDrive/Documents/Noise/backend").
lib.
create_empty(D) :-
py_call(helper:create_empty(), D).
append_left(D, A, ND) :-
py_call(helper:append_left(D, A), ND).
So I tried running append_left
, but I get this error:
?- create_empty(D), append_left(D, 1, D1).
ERROR: Python 'AttributeError':
ERROR: 'list' object has no attribute 'appendLeft'
ERROR: Python stack:
ERROR: File "c:\users\vatis\onedrive\documents\noise\backend\helper.py", line 15, in append_left
ERROR: def append_left(deq, a):
ERROR: ^^^^^^^^^^^^^^
ERROR:
ERROR: In:
ERROR: [14] janus:py_call(helper:append_left([],1),_1770)
ERROR: [11] toplevel_call(user:user: ...) at c:/program files/swipl/boot/toplevel.pl:1317
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
Python thinks the object is a list, but in the second line of the function I have deq = deque(deq)
which should turn the list into a python deque.
It might be possible that Janus did not refresh or something because the previous version of the file did not have that line. I do not know how to refresh Janus to update if there is a way though.
Any ideas? Thanks in advance.