示例#1
0
        public void TestImportModule()
        {
            using (Py.GIL())
            {
                dynamic sys = ps.Import("sys");
                Assert.IsTrue(ps.Contains("sys"));

                ps.Exec("sys.attr1 = 2");
                var value1 = ps.Eval <int>("sys.attr1");
                var value2 = sys.attr1.As <int>();
                Assert.AreEqual(2, value1);
                Assert.AreEqual(2, value2);

                //import as
                ps.Import("sys", "sys1");
                Assert.IsTrue(ps.Contains("sys1"));
            }
        }