loadlj / python-spidermonkey

Automatically exported from code.google.com/p/python-spidermonkey
GNU General Public License v2.0
0 stars 0 forks source link

documentation error #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The tutorial erroneously claims you can't call a function defined in JS -- but 
YES you can:

cx.eval_script("function foo(x) { return x + 1; }; foo(23);")

will return 24, as expected.  The error in the tutorial is that the string just 
ends with foo; and NOT 
a CALL to foo, as in my foo(23)...!

Original issue reported on code.google.com by alea...@gmail.com on 5 Aug 2008 at 2:23

GoogleCodeExporter commented 9 years ago
I think what the tutorial is trying to claim, but in a slightly confusing 
manner, is
that you can't directly call a JavaScript function from Python - i.e. you can't 
do:

  foo = cx.eval_script("function foo(x) { return x + 1; }; foo;")
  print foo(2)

Original comment by jribb...@gmail.com on 25 Sep 2008 at 10:29