Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to make assertion in pyswip written to .pl file

114 views
Skip to first unread message

pradip pramanick

unread,
Apr 22, 2019, 7:56:16 AM4/22/19
to pyswip

I have a pre-populated '.pl' file that contains facts and rules. I open the file using pyswip's consult() method. For example, there are two facts about an object's pickability:
pickable_object(pen).
pickable_object(paper).

Now after I add a new fact using pyswip:

prolog.assertz('pickable_object(light)')

The query

for result in prolog.query('pickable_object(X)'):
    print(result)

works perfectly and it prints:

{'X': 'pen'} {'X': 'paper'} {'X': 'light'}

But, the assertion does not get written to the '.pl' file. How do I enable this?


As a workaround, I am simply appending the new clause string as a new line, treating as a text file. Is this fine?

Reply all
Reply to author
Forward
0 new messages