Enumerate Python objects in JavaScript
Reported by Paul J. Davis | March 25th, 2009 @ 06:58 PM
I haven't gotten the "for(var f in foo)" syntax working when foo is a wrapped Python object.
Comments and changes to this ticket
-
Paul J. Davis March 25th, 2009 @ 07:02 PM
- Tag changed from python-wrapping to python, wrapping
-
Paul J. Davis May 9th, 2009 @ 07:50 PM
- Tag changed from python, wrapping to iterators, python, wrapping
- State changed from new to open
I have the initial support for iterating python objects in the JS vm. This syntax is supported:
for(var v in obj) { // do something with v }
But I still have to add a check so that I can do the following syntax:
for each(var v in obj) { // do something with v }
The difference being that 'for()' returns the property names (or indexes for arrays) while 'for each()' returns the value associated with each property (or array index).
This should be fairly straightforward to add because the next() function gets passed a boolean value that indicates if it wants the name vs. the value.
-
Paul J. Davis May 9th, 2009 @ 10:33 PM
- State changed from open to resolved
(from [fd5307a25d574ec655e41929a8a4a1be860068ca]) 'for each' iteration support in JavaScript.
Added the 'for each(var v in obj)' semantics to iteration.
[#1 state:resolved] http://github.com/davisp/python-...
-
Paul J. Davis May 18th, 2009 @ 07:32 PM
(from [e75f991342e41d62647aa5f557eaff784598ff4b]) Fix integer property lookups.
>>> rt = spidermonkey.Runtime() >>> cx = rt.new_context() >>> cx.add_global("bang", [2, "got me!"]) >>> assert cx.execute("bang[1];") == "got me!"
Thanks to spahl for the report and fix.
[#16 state:resolved] http://github.com/davisp/python-spidermonkey/commit/e75f991342e41d6...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Python/JavaScript bridge module, making use of Mozilla's spidermonkey JavaScript implementation. Allows implementation of JavaScript classes, objects and functions in Python, and evaluation and calling of JavaScript scripts and functions respectively. Borrows heavily from Claes Jacobssen's Javascript Perl module, in turn based on Mozilla's 'PerlConnect' Perl binding.
People watching this ticket
Referenced by
- 1 Enumerate Python objects in JavaScript [#1 state:resolved] http://github.com/davisp/python-...