Exemple #1
0
        public void TestVariables()
        {
            (ps.Variables() as dynamic)["ee"] = new PyInt(200);
            var a0 = ps.Get <int>("ee");

            Assert.AreEqual(200, a0);

            ps.Exec("locals()['ee'] = 210");
            var a1 = ps.Get <int>("ee");

            Assert.AreEqual(210, a1);

            ps.Exec("globals()['ee'] = 220");
            var a2 = ps.Get <int>("ee");

            Assert.AreEqual(220, a2);

            using (var item = ps.Variables())
            {
                item["ee"] = new PyInt(230);
            }
            var a3 = ps.Get <int>("ee");

            Assert.AreEqual(230, a3);
        }
 public static PyObject GetFunction(this PyScope scope, string funcName)
 {
     using (Py.GIL()) {
         return(scope.Variables()[funcName]);
     }
 }