PEP 318 - Function Modifier Syntax

Ian Bicking ianb at colorstudy.com
Tue Jun 10 18:23:22 EDT 2003


On Tue, 2003-06-10 at 16:57, Erik Max Francis wrote:
> The problem with using `is' is that it already has a very specific
> meaning, namely in the use of the `is' operator.  

Note that "in" is already overloaded in the same way, i.e., it is an
operator, and it is a keyword when used with "for".  I don't think this
confuses anyone (though perhaps that's because there's more symmetry in
the two meanings).

I think "as" is a bit better, as it expresses what's going on a bit
better (which isn't really declarative, and "is" feels very
declarative).  I think that syntactic sugar is just as important as it
is with "for" -- things like "def classmethod foo(self):" or "def
foo(self) [classmethod]" don't look good to me.

I can imagine the alternate interpretation of "as" that would be:

    def foo(self) as classmethod: ...

being equivalent to:

    def foo(self): ...
    classmethod = foo
    del foo

Which is the analog of import...as, even if it is a useless analog.  The
analog of "is" might be:

    def foo(self) is classmethod: ...
    assert foo is classmethod

Which isn't true, though again such a meaning would be quite useless. 
It helps that isinstance(foo, classmethod) is true.

  Ian







More information about the Python-list mailing list