Brython - Python in the browser

Ian Kelly ian.g.kelly at
Fri Dec 21 22:17:57 CET 2012

On Fri, Dec 21, 2012 at 1:59 PM, Pierre Quentel
<pierre.quentel at> wrote:
>> By the way, what is Brython actually doing when you append a child to
>> the document itself like that?  Usually I would expect a div to be
>> appended to the body or to another div.  The above looks like it would
>> attach the new div as a sibling of the html element.  Or is it just
>> calling document.write()?
> dom_elt <= obj actually adds one or several DOM nodes (it depends of the class of obj) to the DOM node represented by dom_elt. It's difficult to explain all the cases here, you would have to take a look at the code in py_dom.js, but <= and + work on the DOM tree, there is no document.write anywhere

Thanks, I found my answer in the source: doc <= element basically
calls document.body.appendChild(element)

More information about the Python-list mailing list