Brython - Python in the browser

Pierre Quentel pierre.quentel at
Fri Dec 21 17:36:22 CET 2012

> Hmm. So when that gets added into a DIV, it has to get parsed for
> tags? How does this work? This seems very odd. I would have expected
> it to remain as DOM objects.

In DIV(child) :
- if child is a string, integer or float, a text node is added (addChild) to the DIV element, with the string value of child
- if child is another DOM element (as in DIV(B('foo'))) then this element is added to the DIV element

The code is in module py_dom.js, class $TagClass

> What happens if I do, for instance:
> 'blah blah x<y: '+B('True!')
You can test this code in the console on the Brython site ( :

doc <= 'blah blah x<y: '+B('True!')

It will add a text node to the document, with the string 'blah blah x<y: ' followed by 'True!' in bold characters

- Pierre

More information about the Python-list mailing list