Package sanskrit

Class PyModule

java.lang.Object
sanskrit.PyModule

public final class PyModule extends Object
A builtin module such as math.
  • Constructor Details

    • PyModule

      public PyModule(String name)
  • Method Details

    • put

      public PyModule put(String fn, Builtin.Fn body)
      Adds a function written in Java, callable as name.fn(...) from Python.
    • putString

      public PyModule putString(String constant, String value)
      Adds a constant string, readable as name.constant.
    • putStringMap

      public PyModule putStringMap(String constant, Map<String,String> values)
      Adds a constant dict of strings, in the order of the map.
    • stringDict

      public static Object stringDict(Map<String,String> values)
      A new dict of strings, in the order of the map: the value a function returns.
    • putPlain

      public PyModule putPlain(String constant, Object value)
      Adds a constant built from plain Java values: a Map with String keys becomes a dict (in the order of the map), a List a list, a String a str. Nothing else is accepted: no Java object is ever exposed to a script.
    • get

      public Object get(String fn)
      The member called fn (a function, for instance), or null.