Easy¶
- exception pyswip.easy.InvalidTypeError(*args)¶
- exception pyswip.easy.ArgumentTypeError(expected, got)¶
Thrown when an argument has the wrong type.
- pyswip.easy.getAtomChars(t)¶
If t is an atom, return it as a string, otherwise raise InvalidTypeError.
- pyswip.easy.getAtom(t)¶
If t is an atom, return it , otherwise raise InvalidTypeError.
- pyswip.easy.getBool(t)¶
If t is of type bool, return it, otherwise raise InvalidTypeError.
- pyswip.easy.getLong(t)¶
If t is of type long, return it, otherwise raise InvalidTypeError.
- pyswip.easy.getInteger(t)¶
If t is of type long, return it, otherwise raise InvalidTypeError.
- pyswip.easy.getFloat(t)¶
If t is of type float, return it, otherwise raise InvalidTypeError.
- pyswip.easy.getString(t)¶
If t is of type string, return it, otherwise raise InvalidTypeError.
- pyswip.easy.getDict(term)¶
Return term as a dictionary.
- pyswip.easy.getList(x)¶
Return t as a list.
- pyswip.easy.getFunctor(t)¶
Return t as a functor
- pyswip.easy.registerForeign(func, name='', arity=None, flags=0)¶
Registers a Python callable as a Prolog predicate
- Parameters:
func (
Callable) – Callable to be registered. The callable should return a value inforeign_t,TrueorFalse.name (
str) – Name of the callable. If the name is not specified, it is derived fromfunc.__name__.arity (
Optional[int]) – Number of parameters of the callable. If not specified, it is derived from the callable signature.flags (
int) – Only supported flag isPL_FA_NONDETERMINISTIC.
See: PL_register_foreign.
Note
This function is deprecated. Use
Prolog.register_foreign()instead.
- pyswip.easy.call(*terms, **kwargs)¶
Call term in module.
term: a Term or term handle
- pyswip.easy.newModule(name)¶
Returns a module with the given name.
The module is created if it does not exist.
Note
This function is deprecated. Use
moduleinstead.- Parameters:
name (
Union[str,Atom]) – Name of the module- Return type:
c_void_p
- pyswip.easy.module(name)¶
Returns a module with the given name.
The module is created if it does not exist.
- Parameters:
name (
Union[str,Atom]) – Name of the module- Return type:
c_void_p