SourceForge has been redesigned. Learn more.
Close

Diff of /doc/source/pyke_syntax/kqb_syntax.txt [5cabfd] .. [4dca5a]  Maximize  Restore

Switch to unified view

a/doc/source/pyke_syntax/kqb_syntax.txt b/doc/source/pyke_syntax/kqb_syntax.txt
...
...
404
        $ans = integer(0-100) 
404
        $ans = integer(0-100) 
405
            -10   ! more than that!
405
            -10   ! more than that!
406
            10-20 ! bingo!
406
            10-20 ! bingo!
407
            21-   ! I guess they're not as strong as you think ...
407
            21-   ! I guess they're not as strong as you think ...
408
408
409
.. This code is hidden.  It will add '' to sys.path, change to the doc.examples
410
   directory and store the directory path in __file__ for the code section
411
   following:
412
   >>> import sys
413
   >>> if '' not in sys.path: sys.path.insert(0, '')
414
   >>> import os
415
   >>> os.chdir("../../examples")
416
   >>> __file__ = os.getcwd()
417
409
Asking ``stupid_question`` and answering "y" to it::
418
Asking ``stupid_question`` and answering "y" to it::
410
419
411
    >>> from pyke import knowledge_engine
420
    >>> from pyke import knowledge_engine
412
421
413
    >>> engine = knowledge_engine.engine('doc.examples')
422
    >>> engine = knowledge_engine.engine(__file__)
414
423
415
    >>> from io import StringIO
424
    >>> from io import StringIO
416
    >>> import sys
425
    >>> import sys
417
    >>> class echo(object):
426
    >>> class echo(object):
418
    ...     def __init__(self, f): self.f = f
427
    ...     def __init__(self, f): self.f = f
...
...
422
    ...         return ans
431
    ...         return ans
423
    >>> sys.stdin = echo(StringIO('y\n'))
432
    >>> sys.stdin = echo(StringIO('y\n'))
424
433
425
displays::
434
displays::
426
435
427
    >>> engine.prove_1('user_questions', 'stupid_question', (), 1)
436
    >>> engine.prove_1_goal('user_questions.stupid_question($ans)')
428
    ______________________________________________________________________________
437
    ______________________________________________________________________________
429
    Can you answer a question
438
    Can you answer a question
430
    that is several lines long? (y/n) y
439
    that is several lines long? (y/n) y
431
    Correct!  This is true because the
440
    Correct!  This is true because the
432
              sky is blue!
441
              sky is blue!
433
    ((True,), None)
442
    ({'ans': True}, None)
434
443
435
444
436
Select_1_type
445
Select_1_type
437
=============
446
=============
438
447