Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; '21,': 0.07; 'builtin': 0.07; 'converts': 0.07; 'parsing': 0.07; 'run,': 0.07; 'string;': 0.07; 'strings.': 0.07; 'api': 0.09; '22,': 0.09; 'expectation': 0.09; 'literal': 0.09; 'objects.': 0.09; 'parsed': 0.09; 'typed': 0.09; 'dec': 0.15; 'sat,': 0.15; 'element,': 0.16; 'hmm.': 0.16; 'literal,': 0.16; 'result:': 0.16; 'string': 0.17; 'wrote:': 0.17; 'element': 0.17; 'integer': 0.17; 'string,': 0.17; '>>>': 0.18; 'code.': 0.20; 'followed': 0.20; 'doc': 0.22; 'seems': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'plain': 0.27; '(as': 0.27; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'chris': 0.28; 'bold': 0.29; 'clicked': 0.29; 'document,': 0.29; 'dom': 0.29; 'node': 0.29; 'prints': 0.29; 'str': 0.29; 'fri,': 0.30; 'gets': 0.32; 'structure': 0.32; 'getting': 0.33; 'right?': 0.33; 'text,': 0.33; 'to:addr:python- list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'adds': 0.35; 'text.': 0.35; 'expected': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'child': 0.36; 'test': 0.36; 'should': 0.36; 'does': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'tags,': 0.81; '(is': 0.84; 'float,': 0.84; 'to:name:python': 0.84; 'was:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=l7pIVpudB/p4Q8kvAhwCJt+jxLbwBCHoziSU3HlwfRA=; b=Gt8KTZkYzv3agfGiUMT55P5l57CrWrCyI2dpGrjPM0Ad3TMQe3lq7eCMzb9CrWjeta RjEJtg4PQ+ekQawrNRbWEqd2fjmxFw8TNB63IS9IZS5hKweu2OAtRlZR+l8ze3LE/u3J NdwHb8IsdGWyVQNsyYPbvSp52ZcXq6rr4+j5zbDHv/T1cPlhSXkCxx2vfu+sWymRct9r AsAnuiE2onweeZAjEqoaMr5iGc+D8BW4TY2wrkGJT2wI0jLzhT+uKHqVKh1sQLAX3OOP a8128GBr8AaTSZyok/i9hFL3sEOOBA+YLg5NoDYdgDGfd9864Xw2lpv6TZmOy6HDIznf C6eA== MIME-Version: 1.0 In-Reply-To: References: <50D256B3.4070709@udel.edu> <96edb672-dabd-4ab8-9e7c-3fa7f4a91437@googlegroups.com> <44335f22-555a-4806-b24a-7d4cb1d8e529@googlegroups.com> <4ddee631-b5b5-4cb4-82b0-00ca403b773e@googlegroups.com> From: Ian Kelly Date: Fri, 21 Dec 2012 16:45:03 -0700 Subject: Re: Brython - Python in the browser To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356133541 news.xs4all.nl 6932 [2001:888:2000:d::a6]:49246 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35326 On Fri, Dec 21, 2012 at 3:52 PM, Chris Angelico wrote: > On Sat, Dec 22, 2012 at 3:36 AM, Pierre Quentel > 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 <=

' > will add literal text, not a paragraph object, right? That's > definitely what I would expect. > >> doc <= 'blah blah x> >> It will add a text node to the document, with the string 'blah blah x > 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 > strings. > > Do you see now what I mean about the API being difficult to explain? In my playing around with it just now, the addition doesn't seem to actually return a string. I typed this script into the test console: log('hello ' + B('world')) and clicked Run, and the result was: [object Object] whereas if I just try to log a plain string literal, it actually prints out the string. Somewhat disturbingly, this also gives the [object Object] result: log(str('hello ' + B('world'))) In Brython, the str builtin does not return strings?