Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17591

Re: Grammar for classes

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'all).': 0.09; 'generators': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'runtime': 0.09; 'underlying': 0.09; 'am,': 0.12; 'exception': 0.12; '2.7': 0.13; 'clause.': 0.16; 'enigma': 0.16; 'expression,': 0.16; 'kern': 0.16; 'subject:classes': 0.16; 'tried:': 0.16; 'syntax': 0.16; 'wrote:': 0.18; '3.2': 0.18; 'seems': 0.20; 'written': 0.20; 'thorough': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'thus': 0.23; 'versions': 0.23; 'clause': 0.23; 'defined': 0.24; 'extent': 0.24; 'suspect': 0.24; 'says': 0.25; "i'm": 0.26; 'anyway.': 0.29; 'expressions': 0.29; 'interpret': 0.29; 'sorry,': 0.29; 'pm,': 0.29; 'class': 0.29; 'construct': 0.30; 'remains': 0.30; "i've": 0.31; 'version': 0.32; 'does': 0.32; 'actual': 0.32; "won't": 0.33; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'agree': 0.33; 'object': 0.33; 'to:addr:python-list': 0.34; 'rule': 0.34; 'file.': 0.34; 'surprised': 0.34; 'thus,': 0.34; 'url:python': 0.36; '(to': 0.37; 'class.': 0.37; 'for?': 0.37; 'but': 0.37; 'except': 0.37; 'reference': 0.37; 'think': 0.37; 'received:org': 0.38; 'allows': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'goes': 0.39; 'why': 0.39; "it's": 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'kind': 0.61; 'world': 0.62; 'our': 0.64; 'harder': 0.64; 'believe': 0.65; 'relevant': 0.70; 'soon.': 0.71; 'anytime': 0.74; 'received:109': 0.78; 'thee': 0.84; 'url:reference': 0.84; 'eco': 0.91; 'speaks': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: Grammar for classes
Date Tue, 20 Dec 2011 17:20:12 +0000
References <CAN1F8qWV1j-2VDvMyh47dxfj4G_yXSP8rcUdmpBY-HLrD5gaUQ@mail.gmail.com> <jcppjc$va7$1@dough.gmane.org> <CAN1F8qXjE0zPrUjC-Kih=gCm=pv4mwGPCvT+Y5EE3XVwVw3WwA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host109-153-163-100.range109-153.btcentralplus.com
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <CAN1F8qXjE0zPrUjC-Kih=gCm=pv4mwGPCvT+Y5EE3XVwVw3WwA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3871.1324401626.27778.python-list@python.org> (permalink)
Lines 56
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324401626 news.xs4all.nl 6875 [2001:888:2000:d::a6]:41402
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17591

Show key headers only | View raw


On 12/20/11 5:05 PM, Joshua Landau wrote:
> On 20 December 2011 10:55, Robert Kern <robert.kern@gmail.com
> <mailto:robert.kern@gmail.com>> wrote:
>
>     On 12/20/11 1:34 AM, Joshua Landau wrote:
>
>         In reading thorough the syntax defined in the reference
>         <http://docs.python.org/py3k/__reference/compound_stmts.html#__class-definitions
>         <http://docs.python.org/py3k/reference/compound_stmts.html#class-definitions>>,
>
>         the class statement has surprised me.
>
>         It says that the inheritance part of the class can accept
>         comprehensions. What
>         does this mean?
>         I've tried:
>         "class A(x for x in ()): pass"
>         but this doesn't need the extra clause as "x for x in ()" is an
>         expression, and
>         thus this evaluates:
>         "class A(x for x in (),): pass"
>         although again it won't be a valid class anytime soon.
>
>         So what is this clause for?
>
>
>     I suspect that it's harder to make a grammar rule that allows every kind of
>     expression except for generator expressions than it is just to reuse the
>     "testlist" rule and let the runtime reject the generator object when it goes
>     to construct the class.
>
>
> The thing is, as far as I can tell, the grammar would be the same without the
> added clause. That is because it's a valid grammar anyway. The only exception I
> can think of is if generators were treated exceptionally. Thus, while I agree it
> makes complete sense to make it a runtime error, the clause in the specification
> seems to be fluff.
>
> Also - what is this "testlist" rule thee speaks of?

Sorry, I was looking at the actual 2.7 Grammar file. "testlist" has been renamed 
to "arglist" in the 3.2 version of the Grammar, but the substantive point I made 
remains (to the extent that it is relevant at all).

That said, the documentation for both versions differs from a simple restatement 
of the Grammar rules, so I'm not sure exactly why the documentation is written 
the way it is.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Grammar for classes Robert Kern <robert.kern@gmail.com> - 2011-12-20 17:20 +0000

csiph-web