Brython - Python in the browser

Chris Angelico rosuav at
Fri Dec 21 23:52:49 CET 2012

On Sat, Dec 22, 2012 at 3:36 AM, Pierre Quentel
<pierre.quentel at> wrote:
>> 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

Meaning that:
doc <= <p></p>'
will add literal text, not a paragraph object, right? That's
definitely what I would expect.

> 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

This is where it's getting confusing. My expectation of this is that
it adds a text node with the literal text, followed by a bold node
with its child text. This operation should never involve the parsing
of HTML tags, as the document structure is all there in the code. So
it ought to be a DOM object, not a text string, that gets <='d onto
doc (is <= a verb now?). That means the result of the addition has to
be a DOM object, not a text string; but you said that adding a string
to a B object converts the object to a string and concatenates the

Do you see now what I mean about the API being difficult to explain?


More information about the Python-list mailing list