Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Bounty Awarded with 25 reputation awarded by Community Bot
Added note on documentation
Source Link
user785541
user785541

Injecting a Python function into JavaScript context is actually very simple - you assign that function to a local variable via JSContext.locals object:

ctx = PyV8.JSContext()
ctx.enter()
ctx.locals.prompt = raw_input
ctx.eval('var a = prompt("foo>"js> ")';')

And all the sudden you can use that Python function from JavaScript exactly like you would do it in Python.

I would normally link to the documentation but PyV8 documentation doesn't appear to be available anywhere with the proper MIME type.

Injecting a Python function into JavaScript context is actually very simple - you assign that function to a local variable via JSContext.locals object:

ctx = PyV8.JSContext()
ctx.enter()
ctx.locals.prompt = raw_input
ctx.eval('var a = prompt("foo> ")')

And all the sudden you can use that Python function from JavaScript exactly like you would do it in Python.

Injecting a Python function into JavaScript context is actually very simple - you assign that function to a local variable via JSContext.locals object:

ctx = PyV8.JSContext()
ctx.enter()
ctx.locals.prompt = raw_input
ctx.eval('var a = prompt("js> ");')

And all the sudden you can use that Python function from JavaScript exactly like you would do it in Python.

I would normally link to the documentation but PyV8 documentation doesn't appear to be available anywhere with the proper MIME type.

Source Link
user785541
user785541

Injecting a Python function into JavaScript context is actually very simple - you assign that function to a local variable via JSContext.locals object:

ctx = PyV8.JSContext()
ctx.enter()
ctx.locals.prompt = raw_input
ctx.eval('var a = prompt("foo> ")')

And all the sudden you can use that Python function from JavaScript exactly like you would do it in Python.

default

AltStyle によって変換されたページ (->オリジナル) /