Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Enumerate Python objects in JavaScript

#1

I haven't gotten the "for(var f in foo)" syntax working when foo is a wrapped Python object.

Reported by Paul J. Davis · March 25th, 2009 @ 06:58 PM

State: resolved
Milestone: none
Assigned to: Paul J. Davis Paul J. Davis

Activity

  1. Paul J. Davis
    Paul J. Davis
    • Tag changed from python-wrapping to python, wrapping

    March 25th, 2009 @ 07:02 PM

  2. Paul J. Davis
    Paul J. Davis
    • 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.

    May 9th, 2009 @ 07:50 PM

  3. Paul J. Davis
    Paul J. Davis
    • 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 Enumerate Python objects in JavaScript state:resolved] http://github.com/davisp/python-...

    May 9th, 2009 @ 10:33 PM

  4. Paul J. Davis
    Paul J. Davis

    (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 TypeError: bad argument type for built-in operation state:resolved] http://github.com/davisp/python-spidermonkey/commit/e75f991342e41d6...

    May 18th, 2009 @ 07:32 PM

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.