javascript to python

lkcl luke.leighton at
Thu Oct 2 20:07:19 CEST 2008

On Oct 2, 5:54 pm, Joe Hrbek < at> wrote:
> Could someone help me translate to something that would close to it in
> python?  The anonymous functions are giving me problems.

class dataListener:
    def __init__(self):
        data = ""
    def onStartRequest(self, request, context):
    def onStopRequest(self, request, context, status):

        # TODO: pass these three in to dataListener as
        # params to the constructor, so it's
        # def __init__(self, instream, outstream, listener)
        # and do self.instream = instream

        global instream
        global outstream
        global listener


    def onDataAvailable(self, request, context, inputStream,
                        offset, count):

        global instream +=


why are request and context being ignored?
why is there an inputStream argument to onDataAvailable, yet
there's a global variable (in the javascript) called
instream?  is it the same?

all this, and more, thanks to the awfulness that is javascript :)

for fits and giggles, compile the above python using, the python-to-javascript compiler
(see and compare the
resultant javascript to your original code-fragment.


More information about the Python-list mailing list