?- py_call(blessed:'Terminal',B), py_call(B:height,H).
B = <py_type>(00000205cb85ad30),
H = <py_property>(00000205cbd63740).
I’m trying to access the height property of the Terminal() class from the blessed package (“not only” a wrapper around ncurses).
In Python I just get the height directly like this:
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import blessed
>>> term = blessed.Terminal()
>>> term.height
56
I tried wrapping H to str() and printing it and a bunch of other tricks I could think of but that doesn’t work. How do I access the value of a Python property with Janus?
But, in general, try to avoid intermediate result. They cause objects to be garbage collected, but after a delay. You may also need the option py_object(true) to avoid the intermediate result being translated to Prolog. Whether or not you need that depends on the object type, but if you want an object reference, the safe way is to use this option.