Term_variable/2 behavior from Python via swiplserver

Thanks for your answer. Yes I agree that the answer is “equivalent”, but it makes life harder as I need to recover the original name in Python.

Sorry I should have been more complete in my code. I am using swiplserver

$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from swiplserver import PrologMQI, PrologThread
>>> pl = PrologMQI().create_thread()
>>> pl.query("term_variables(q1(X, Y), P)")
[{'X': 'A', 'Y': 'B', 'P': ['A', 'B']}]
>>> 

I was not sure what is the difference between swiplserver and Janus but I found a good explanation from Jan here. Seems swiplserver is more powerful/flexible, but with a bit more overhead.