Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35287
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| 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; 'python,': 0.02; 'operator': 0.03; 'syntax': 0.03; 'subject:Python': 0.05; 'reject': 0.05; '21,': 0.07; 'api': 0.09; 'python': 0.09; 'methods,': 0.09; 'surrounded': 0.09; 'url:github': 0.09; 'will,': 0.09; 'dec': 0.15; "skip:' 30": 0.15; 'api,': 0.16; 'cheap,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'means:': 0.16; 'operators,': 0.16; 'parentheses': 0.16; 'parentheses:': 0.16; 'pythonic': 0.16; 'syntax,': 0.16; 'verbose': 0.16; 'version;': 0.16; 'string': 0.17; 'wrote:': 0.17; 'instance,': 0.17; 'ideal': 0.20; 'proposed': 0.20; 'bit': 0.21; 'doc': 0.22; 'parse': 0.22; 'defined': 0.22; 'example': 0.23; 'nearly': 0.23; "python's": 0.23; 'this:': 0.23; 'thus': 0.24; 'idea': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'creating': 0.26; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'concise': 0.29; 'dom': 0.29; 'wrap': 0.29; 'fri,': 0.30; 'expect': 0.31; 'code': 0.31; 'structure': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'self': 0.34; 'wrong': 0.34; 'returning': 0.35; 'skip:. 20': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'list.': 0.35; 'except': 0.36; 'explain': 0.36; 'but': 0.36; 'totally': 0.36; 'method': 0.36; 'bad': 0.37; 'does': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'kind': 0.61; 'world': 0.63; 'more': 0.63; 'sum': 0.66; 'taxes': 0.71; 'children.': 0.75; 'url:master': 0.84; 'wait,': 0.93 |
| 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=u1ewt13gvyUp05XzVfh5QQqkmovKEi3PwkGFfRhUUfA=; b=1HEit/YxBxeN6/Bq/dKp4ZcdcvmJ6yGehUcMrNvxRCL4ttxupOixlJ6wIYnQVfBpCC 832KlvdDK2g+OO6XfUZDT9Swfxyl8Q+5CPgp7vGLcDxXsYnntc2lJ1zRLuuxDziPIe8K 1Bsz4/+DgI9dxT4hu4j0NnnEES7V3HtjB9dzsVDPRILK/gwO7Ty5d8CDVAr67j43ND59 uexCflgsHoCQyFHJanWeFO0A1nXD0T92DTb/YaYkhvHoL3hNFBwLebhsmZl2m9aMLnI6 21hsJFWN1Ja92tDk+vTJx3ILcLLmiSJ+cxl+5YaVWRATpWAIpRNgne7B66JQl60YuHr8 4Gdw== |
| MIME-Version | 1.0 |
| In-Reply-To | <c1663198-d1b0-4e7d-b8d8-e1b6d63b4f55@googlegroups.com> |
| References | <c0be76ec-d55b-4f6c-9892-a80b482ff5bb@googlegroups.com> <50D256B3.4070709@udel.edu> <mailman.1082.1355964916.29569.python-list@python.org> <96edb672-dabd-4ab8-9e7c-3fa7f4a91437@googlegroups.com> <mailman.1143.1356089120.29569.python-list@python.org> <c1663198-d1b0-4e7d-b8d8-e1b6d63b4f55@googlegroups.com> |
| Date | Fri, 21 Dec 2012 23:57:58 +1100 |
| Subject | Re: Brython - Python in the browser |
| From | Chris Angelico <rosuav@gmail.com> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1146.1356094682.29569.python-list@python.org> (permalink) |
| Lines | 54 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356094682 news.xs4all.nl 6953 [2001:888:2000:d::a6]:45389 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35287 |
Show key headers only | View raw
On Fri, Dec 21, 2012 at 11:38 PM, Pierre Quentel
<pierre.quentel@gmail.com> wrote:
> With the tree syntax proposed in Brython it would just be
>
> doc <= DIV('hello '+B('world'))
>
> If "pythonic" means concise and readable, which one is more pythonic ?
Pythonic also means:
If the implementation is hard to explain, it's a bad idea.
What, exactly, does the sum of a string and a bolded string produce?
Can you explain that easily and clearly? Don't forget that humans, as
well as machines, will expect to be able to parse what's inside the
parentheses without looking outside them.
The DOM structure is, undeniably, quite verbose. But you could go for
something with the same tree structure while a lot less wordy by
simply returning self from lots of methods, thus allowing method
chaining - something like this:
https://github.com/Rosuav/Gypsum/blob/master/window.pike#L247
Note how the tree structure is defined by the parentheses, with
->add(...) calls creating children. (That's Pike, not Python, as I
don't have a good Python example handy. The -> operator does more or
less what Python's . does.) Now, I can conceive of a kind of API - an
ideal API, the creature of my fancy, you know - which would be totally
unobjectionable. An API, for instance, which would abolish taxes and
make everything cheap, except gondolas... oh wait, wrong mailing list.
To produce the HTML code
<DIV>hello <B>world</B></DIV>
you might use:
doc.add(Tag('DIV').add('hello ').add(Tag('B').add('world')))
And you can easily wrap that to suit, since it's surrounded by parentheses:
doc.add(
Tag('DIV')
.add('hello ')
.add(Tag('B').add('world'))
)
There's no magic with operators, just simple method chaining. It's a
bit more verbose than your proposed tree syntax, but not nearly as bad
as the JS version; and it's not magical.
Reject the idea if you will, but do at least please consider it :)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-19 10:19 -0800
Re: Brython - Python in the browser jkn <jkn_gg@nicorp.f9.co.uk> - 2012-12-19 14:59 -0800
Re: Brython - Python in the browser Terry Reedy <tjreedy@udel.edu> - 2012-12-19 19:07 -0500
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-20 01:37 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-20 20:56 +1100
Re: Brython - Python in the browser Terry Reedy <tjreedy@udel.edu> - 2012-12-20 18:59 -0500
Re: Brython - Python in the browser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-21 02:05 +0000
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-21 16:07 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 08:16 -0800
Re: Brython - Python in the browser Stefan Behnel <stefan_ml@behnel.de> - 2012-12-21 17:52 +0100
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-21 11:31 -0700
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 12:59 -0800
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-21 14:17 -0700
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 12:59 -0800
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 08:16 -0800
Re: Brython - Python in the browser Rouslan Korneychuk <rouslank@msn.com> - 2012-12-21 03:31 -0500
Re: Brython - Python in the browser Terry Reedy <tjreedy@udel.edu> - 2012-12-21 04:44 -0500
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-20 01:37 -0800
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-19 17:54 -0700
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-20 01:42 -0800
Re: Brython - Python in the browser Stefan Behnel <stefan_ml@behnel.de> - 2012-12-21 12:25 +0100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 04:38 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-21 23:57 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 07:36 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 02:48 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 08:36 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 09:52 +1100
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-21 16:45 -0700
Re: Brython - Python in the browser Amirouche Boubekki <amirouche.boubekki@gmail.com> - 2012-12-22 00:50 +0100
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-21 16:51 -0700
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 23:59 -0800
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 23:59 -0800
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-21 16:57 -0700
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 11:08 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 23:57 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 19:31 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-22 00:54 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 20:08 +1100
Re: Brython - Python in the browser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-22 11:05 +0000
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 23:11 +1100
Re: Brython - Python in the browser Dan Sommers <dan@tombstonezero.net> - 2012-12-22 20:31 +0000
Re: Brython - Python in the browser Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-22 13:53 -0700
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-23 08:49 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-22 00:54 -0800
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 23:57 -0800
Re: Brython - Python in the browser Chris Angelico <rosuav@gmail.com> - 2012-12-22 11:09 +1100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 08:36 -0800
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 07:36 -0800
Re: Brython - Python in the browser Duncan Booth <duncan.booth@invalid.invalid> - 2012-12-21 13:14 +0000
Re: Brython - Python in the browser Stefan Behnel <stefan_ml@behnel.de> - 2012-12-21 14:34 +0100
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-21 04:38 -0800
Re: Brython - Python in the browser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-22 02:31 +0000
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-20 01:42 -0800
Re: Brython - Python in the browser Terry Reedy <tjreedy@udel.edu> - 2012-12-19 21:46 -0500
Re: Brython - Python in the browser Jamie Paul Griffin <jamie@kode5.net> - 2012-12-20 11:32 +0000
Re: Brython - Python in the browser Pierre Quentel <pierre.quentel@gmail.com> - 2012-12-22 01:01 -0800
csiph-web