Yes, but you can't use clips.StdinStream and clips.StdoutStream in an effective way. Ok, if you structure your CLIPS subprogram very carefully and pay special attention to the execution order you might also be able to use the default CLIPS streams to provide input from an hypothetical user, but the quickest way to achieve a result is to let Python do the I/O job using a Python function:
def clips_raw_input(prompt): return clips.String(raw_input(prompt)) clips.RegisterPythonFunction(clips_raw_input, "raw-input")
this function will let Python interact with the user, such as in the following session:
>>> import clips >>> def clips_raw_input(prompt): return clips.String(raw_input(prompt)) >>> clips.RegisterPythonFunction(clips_raw_input, "raw-input") >>> r1 = clips.BuildRule( "name-rule", "(initial-fact)", """(bind ?user-name (python-call raw-input "Your Name? ")) (assert (user-name-is ?user-name))""") >>> clips.Reset() >>> clips.Run() Your Name? Francesco 1 >>> clips.PrintFacts() f-0 (initial-fact) f-1 (user-name-is "Francesco") For a total of 2 facts. >>>
Of course you can use raw_input, but you can also pop up a dialog box or whatever else to retrieve input from the interactive session, using virtually all Python possibilities.