views:

303

answers:

1

scope.SetVariable("math", ?? typeof(System.Math) ??);

or do I need create a module?

+2  A: 

You can do:

scope.SetVariable("math", DynamicHelpers.GetPythonTypeFromType(typeof(System.Math)));

DynamicHelpers is in IronPython.Runtime.Types.

Dino Viehland
Thank you !!!!!!!!!!!!!!!!!!!!!!
Boolean
And did you know how to create a ScripeScope that has parent scope?
Boolean
There's no way to do this - while Scope's have a Parent property ScriptScope's don't expose this. The parent property on Scope's is also going away. If you want to chain lookups you should create a ScriptScope w/ your own custom IAttributesCollection which knows how to look in the parent scope.
Dino Viehland
Thank you.I found I could create a Scope with a parent scope using Scope(Scope parent, IAttributesCollection dictionary), and HostingHelpers can create a ScriptScope from a Scope.
Boolean