Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created June 19, 2009 11:06
Show Gist options
  • Save jschementi/132558 to your computer and use it in GitHub Desktop.
Save jschementi/132558 to your computer and use it in GitHub Desktop.
begin
require 'Microsoft.Scripting, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
rescue
require 'Microsoft.Scripting, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null'
end
include Microsoft::Scripting
include Microsoft::Scripting::Hosting
def python(str, type = :file)
@python_engine ||= DynamicApplication.Current.Runtime.
GetEngine("IronPython")
@python_scope ||= @python_engine.CreateScope()
@python_engine.
CreateScriptSourceFromString(str.strip, SourceCodeKind.send(type)).
Execute(@python_scope)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment