Hello everyone! I want to bind a class in C# (or a System.Type) to a variable in IronPython using scope.SetVariable. For example, import System math = System.Math math.Sin(1) # this works type(math) # IronPython.Runtime.Types.PythonType But, I do not want to use "import xxx" due to security problems. I want the "math" class, in this example, can be use instantly.
When I tried to do something like this in C#:
scope.SetVariable("math",typeof(System.Math));
then in python code
type(math) # Also IronPython.Runtime.Types.PythonType
See the attached source file for detailed info.
Something may be useful:
see IronPython.Modules.Builtin, which is also a static class like System.Math.
seems like IronPython binded it with "__builtins__" in python successfully, but
I don't know how.
Another question: is there an easy way to disable users from importing modules
like clr without using Code Access?
Also, how to bind a namespace in C# code, to a ironpython object, using
IronPython C# assembly (so the "binding" code must be written in C#(.NET) code)?
2016-03-19
buckle2000
Program.cs
Description: Binary data
_______________________________________________ Ironpython-users mailing list [email protected] https://mail.python.org/mailman/listinfo/ironpython-users
