Mercurial > pymonkey
comparison docs/rendered/_sources/pymonkey.txt @ 57:a2b617731398
pymonkey.undefined now has a 'falsy' value.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 10 Jul 2009 18:41:14 -0700 |
parents | 72e84bd75905 |
children | 7a3461ccaf1d |
comparison
equal
deleted
inserted
replaced
56:72e84bd75905 | 57:a2b617731398 |
---|---|
23 (JavaScript's ``null`` is mapped to Python's ``None`` object). | 23 (JavaScript's ``null`` is mapped to Python's ``None`` object). |
24 For instance: | 24 For instance: |
25 | 25 |
26 >>> cx = pymonkey.Runtime().new_context() | 26 >>> cx = pymonkey.Runtime().new_context() |
27 >>> cx.evaluate_script(cx.new_object(), '', '<string>', 1) | 27 >>> cx.evaluate_script(cx.new_object(), '', '<string>', 1) |
28 <type 'pymonkey.undefined'> | 28 pymonkey.undefined |
29 | 29 |
30 Unfortunately, this object currently does not have a "falsy" value, | 30 This object also has a "falsy" value: |
31 e.g.: | |
32 | 31 |
33 >>> if pymonkey.undefined: | 32 >>> if not pymonkey.undefined: |
34 ... print 'Huh, this is kind of unintuitive.' | 33 ... print "See, it's falsy!" |
35 Huh, this is kind of unintuitive. | 34 See, it's falsy! |
36 | |
37 The reason for this is simply that we don't currently know how to | |
38 make this object have a falsy value, if it's even possible. | |
39 | 35 |
40 .. class:: Object | 36 .. class:: Object |
41 | 37 |
42 This is the type of JavaScript objects. Such objects can only be | 38 This is the type of JavaScript objects. Such objects can only be |
43 created via Pymonkey calls like :meth:`Context.new_object()` or | 39 created via Pymonkey calls like :meth:`Context.new_object()` or |