I'm using PyV8 and I'd like to call a javascript function with undefined
. It seems that evaluating both undefined
and null
return Python's None
value:
>>> evaljs("undefined")
None
>>> evaljs("null")
None
The problem, of course, is that they're not the same in javascript:
>>> evaljs("undefined === null")
False
False
>>> evaljs("undefined") == evaljs("null")
None
None
True
Is there any nice way to go about doing this? I'd actually like to write a Python function, callable from javascript, which returns undefined
in certain cases and null
in other cases.
EDIT for SSCCE-ness:
import PyV8
context = PyV8.JSContext()
def evaljs(s):
with context:
res = context.eval(s)
print res
return res
The answer is: in the current version there is no way to do this.