[Python-Dev] Re: PEP 244 syntax

M.-A. Lemburg mal@lemburg.com
Mon, 16 Jul 2001 18:49:40 +0200


"Martin v. Loewis" wrote:
> 
> > Well, I guess I would care enough :-) Martin has to change the PEP
> > though, since he's the PEP author.
> 
> I don't like having an equal sign there, but I can add this as an
> alternative and leave it for BDFL pronouncement (and count votes in
> favour or against).
> 
> In any case, I'd need to know what the exact proposed change to PEP
> 244 is. The syntax currently reads
> 
> directive_statement: 'directive' NAME [atom] [';'] NEWLINE
> 
> How do you want this to change?

To make the directive statment useful for setting compiler
parameters, the syntax should be extended to allow
for an (optional) '='. Whether or not this '=' sign must be there
is up to the definition of the directive NAME.

It may also be worthwhile using a testlist (see Grammar)
instead of the fixed atom for cases where the compiler
parameter needs to be a e.g. list of options.

I'd also suggest to remove the optional ';' since this is
not confrom with the rest of Python....

directive_statement: 'directive' NAME ['='] [testlist] NEWLINE
 
> > I think that supporting the typical "key = value" format is
> > quite reasonable for setting flags in the compiler. The PEP's
> > original idea of replacing your "from __future__ import spam"
> > does not require this format, since is only needs to support
> > switches.
> 
> Actually, based on Tim's objections, I need the syntax in a different
> way:
> 
> directive transitional generators
> 
> Here, "directive transitional" indicates that a transitional feature
> is being activated, followed by the name of the feature. This is in
> line with
> 
> directive transitional nested_scopes
> 
> Spelling them as
> 
> directive transitional = nested_scopes
> # or
> directive transitional = 'nested_scopes'
> 
> doesn't sound right, since I'm not assigning to "transitional".

True.
 
> Of course, since this directive is spelled "from __future__ import"
> these days, the only remaining application for directives is the
> unicodeencoding directive. I'm just pointing out that adding an equal
> sign likely restricts the applicability of directives.

It doesn't need to: simply leave the requirement whether to
use or not to use an equal sign to the definition of the 
directive.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/