Today I found, buried deep in the Playground folder on my hard disk, a half finished wxPython implementation of the WineDemo from Gary's ClipsJNI package. I'd completely forgotten about it but I still think it's worth finishing. Not having a good example in Python/pyClips is actually very annoying. Especially if you're, like me, trying to promote Python as a good way to provide a GUI for Clips programs.

So I started going through the code, trying to finish it earlier today but that made me remember why I stopped in the first place. I'm having a lot of trouble converting these two lines of Java into Python:

String evalStr = "(WINES::get-wine-list)";
MultifieldValue pv = (MultifieldValue) clips.eval(evalStr);
The conversion itself is quite simple but I can't get pyClips to evaluate the function, I keep getting this:
>>> clips.Eval("(WINES::get-wine-list)")

Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\lib\site-packages\clips\_clips_wrap.py", line 3430, in Eval
return _cl2py(_c.eval(expr))
ClipsError: C10: unable to evaluate expression
I guess I should I have reported it as a bug.

4 kommentarer:

Gary Riley sa...

Are you using 6.3? Specifying the module name when calling a deffunction isn't allowed in 6.24.

Johan Lindberg sa...

Hmm, that's a good question. I thought I was, but... apparently not.

>>> import clips

I wonder where that DLL is hidden... I don't have that version installed. PyClips probably works very differently from how I imagine it ;-)

Well, at least, that explains my problem. Thanks.

Almost Earthling sa...


no DLL, actually. Python uses its own ".pyd" DLL format, where no function name is exported apart from init_clips(). This, and the fact that Python "prefers" to have its modules compiled with its peculiar options, are the reasons why I decided to recompile CLIPS entirely in the PyCLIPS module.

As I commented on SF, I'll start ASAP to work on CLIPS 6.30, even though I'd prefer its Author to consider it stable, at least on the API side.

Thank you for reporting the issue.



Johan Lindberg sa...

Thanks Franz,

that explains the _clips.pyd file in that folder ;-)

I completely understand if you don't want to support 6.3 while it's in beta. I didn't know that this type of function call was an unsupported feature up until 6.3 and that's why I reported it as a bug.

I'll modify the winedemo.clp file to get the GUI working. I think that's the best way for now and it won't create extra work for you either. So don't feel pressured to start 6.3 earlier on my behalf.