Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'syntax': 0.03; 'subject:Python': 0.05; 'escape': 0.07; '22,': 0.09; 'objects.': 0.09; 'parsed': 0.09; 'structure,': 0.09; 'do,': 0.15; 'library': 0.15; '(but': 0.15; 'dec': 0.15; 'sat,': 0.15; "skip:' 30": 0.15; "'hello": 0.16; '(just': 0.16; 'angle': 0.16; 'bracket': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'instance:': 0.16; 'lambda': 0.16; 'no;': 0.16; 'parentheses': 0.16; 'peers.': 0.16; 'readable': 0.16; 'syntax,': 0.16; 'text?': 0.16; 'string': 0.17; 'wrote:': 0.17; '<': 0.17; 'expanded': 0.17; 'sort': 0.21; 'supposed': 0.21; 'defined': 0.22; 'class.': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'dom': 0.29; 'no,': 0.29; 'expect': 0.31; 'gets': 0.32; 'version:': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'problem,': 0.35; 'skip:. 20': 0.35; 'so,': 0.35; 'doing': 0.35; 'expected': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'level': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'real': 0.61; 'different': 0.63; 'more': 0.63; 'other.': 0.64; 'protect': 0.69; 'obvious': 0.71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cc//zh6FlPPKOK7Mzwn57LyfDIi3kTWqZ32Y/+in8CI=; b=SHgDDQXbekPduMzUZ39TOaU5fVmJC+hnvLD3eF55wbH8QSa82INnwiURvzZL0lLznb lwSGoUqAOK5YR+f3YffJ8BQXH3+a50V4uyoe/scunlHZSWlc9FgadOO2k1tVc2CzgqhZ 4bnTF/WCOtzrNEDWj+hAdenq5vCewoGy136XraakXoL2swb42ZT8GbD4iOqXdrNA6rxF iz1q1bQ32WKdObJLbH0AMI6crpUm/wJOpyszQsdlfeLIUD0Kmv5Zk/g7gfOuxV9e2Lxi HATnBLp0l3B4rn2FbnRB3AmcKcoM8N3zpJuyRw5AFvX8NDiZ9ixz14DAlFolSh4BYJZ2 B+vQ== MIME-Version: 1.0 In-Reply-To: <44335f22-555a-4806-b24a-7d4cb1d8e529@googlegroups.com> References: <50D256B3.4070709@udel.edu> <96edb672-dabd-4ab8-9e7c-3fa7f4a91437@googlegroups.com> <44335f22-555a-4806-b24a-7d4cb1d8e529@googlegroups.com> Date: Sat, 22 Dec 2012 02:48:09 +1100 Subject: Re: Brython - Python in the browser From: Chris Angelico To: python-list@python.org 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356104892 news.xs4all.nl 6878 [2001:888:2000:d::a6]:34523 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35299 On Sat, Dec 22, 2012 at 2:36 AM, Pierre Quentel wrote: >> doc.add(Tag('DIV').add('hello ').add(Tag('B').add('world'))) >> > No, with this syntax, the result of Tag('B').add('world') is below 'hello' in the tree structure, not at the same level (just below Tag('DIV')) as it should be No; look at the expanded form for a more readable (but syntactically identical) version: doc.add( Tag('DIV') .add('hello ') .add(Tag('B').add('world')) ) 'world' is below Tag('B') - look at the parentheses - but Tag('DIV').add('hello ') returns the DIV, not the hello, so B and hello are peers. > In this case it's not a real problem, but it's obvious if you want to produce
  • one
  • two
: you would need 2 different 'add' > top = Tag('UL') > top.add(Tag('LI').add('one')) > top.add(Tag('LI').add('two')) > > With the syntax used in Brython : UL(LI('one')+LI('two')) They can be directly combined, because Tag.add(self,other) returns self, not other. > Yes : a+b returns the string a+str(b) > >>>> 'hello '+B('world') > 'hello world' 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. What happens if I do, for instance: 'blah blah x'+s+'' rather than any sort of class. ChrisA