A counter-proposal to __future__ in PEP 236

Fredrik Lundh fredrik at pythonware.com
Thu Mar 1 13:22:10 EST 2001


Martin von Loewis wrote:
> To selectively activate nested scopes in Python 2.1, PEP 236 proposes
> the "future" statement. That means that you have to write
>
> from __future__ import nested_scopes
>
> Even though this looks like an import statement, it is not: instead,
> it changes the meaning of variable binding in the presence of nested
> functions.

Really?  I'd say it imports an alternate compiler, and activates it
for all modules that happens to contain a from __future__ state-
ment.

> I personally consider this a confusing notation, and propose a
> different syntax, which would read
>
> directive nested_scopes

Note that we're not talking optional standard features here, we're
talking untested experimental stuff, on a scale too large to handle
in an ordinary prerelease cycle.

__future__ stuff may go away or change, if they turn out to be
a bad idea.  If you're easily confused, you shouldn't use them at
all.

But with your proposal, you make them look like optional features.

That isn't just a bad idea, it makes Python look bad too.

> The directive statement currently only supports activating nested
> scopes, but it may get further use later, e.g. to activate
> case-insensitivity or set the source file character set.

Smells like hypergeneralization to me (which is a worse sin than
premature optimization).  Source code encodings and experimental
compiler features are two entirely different things.

> In this implementation, directive is only considered as a keyword if
> it appears at the beginning of the module

And you think from __future__ is a hack?  Gimme a break.

Cheers /F





More information about the Python-list mailing list