comparison docs/src/pymonkey.txt @ 54:234fca1c4b86

Added docs for pymonkey.undefined.
author Atul Varma <varmaa@toolness.com>
date Fri, 10 Jul 2009 17:22:42 -0700
parents 2055d853b995
children 40a404b9c467
comparison
equal deleted inserted replaced
53:2055d853b995 54:234fca1c4b86
13 13
14 .. exception:: error 14 .. exception:: error
15 15
16 This is the type of any SpiderMonkey-related errors thrown by this 16 This is the type of any SpiderMonkey-related errors thrown by this
17 module. 17 module.
18
19 .. data:: undefined
20
21 This is the singleton that represents the JavaScript value
22 ``undefined``, as Python has no equivalent representation
23 (JavaScript's ``null`` is mapped to Python's ``None`` object).
24 For instance:
25
26 >>> cx = pymonkey.Runtime().new_context()
27 >>> obj = cx.new_object()
28 >>> cx.evaluate_script(obj, '', '<string>', 1)
29 <type 'pymonkey.undefined'>
30
31 Unfortunately, this object currently does not have a "falsy" value,
32 e.g.:
33
34 >>> if (pymonkey.undefined):
35 ... print 'Huh, this is kind of unintuitive.'
36 Huh, this is kind of unintuitive.
37
38 The reason for this is simply that we don't currently know how to
39 make this object have a falsy value, if it's even possible.
18 40
19 .. class:: Object 41 .. class:: Object
20 42
21 This is the type of JavaScript objects. Such objects can only be 43 This is the type of JavaScript objects. Such objects can only be
22 created via Pymonkey calls like :meth:`Context.new_object()` or 44 created via Pymonkey calls like :meth:`Context.new_object()` or