[Python-Dev] PEP 318: Let's not give in to FUD
Jeremy Hylton
jeremy at alum.mit.edu
Fri Apr 2 12:05:13 EST 2004
On Fri, 2004-04-02 at 08:24, Barry Warsaw wrote:
> It may be nonsense, but it means something today. So it can't be
> obvious that they're connected because today, they aren't.
Your original complaint was: "What are newcomers going to make of
this?" Newcomers aren't going to be worried about the small change in
semantics that decorator-before would entail, because they won't know
the old semantics. It's only a problem for people who already know the
language, but one would hope they read the "What's New in Python 2.4"
document.
I expect a newcomer to read the code in the most natural way. Only a
language lawyer would worry about whether the expression "[classmethod]"
was evaluated and thrown away rather than referring to fromFoo.
Language lawyers should be clever enough to figure out the new rules
:-).
class Quux:
def __init__(self):
...
[classmethod]
def fromFoo(cls, arg):
"""Create a Quux instance from a Foo."""
...
> If tomorrow this same code means something different, users looking at
> the code will have to know what version of Python they're using, and
> make sure it's the right one ("uh, how do I do that?"). If they were to
> use decorator-before-def code in an older version of Python, the program
> would be accepted but silently do the wrong thing.
I agree there's a risk here, but we've faced that kind of risk before.
We used future statements for nested scopes, but only one version. If
you're looking at code with free variables, you need to know whether it
was written to run with or without nested scopes. Code written for one
version will fail at runtime on the other. (It may or may not fail
silently.)
Jeremy
More information about the Python-Dev
mailing list