[SPAM: 10.000] Re: [Python-Dev] Re: new syntax for wrapping (PEP 318)

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Feb 23 19:40:16 EST 2004

"Jewett, Jim J" <jim.jewett at eds.com>:

> I would have assumed that I have to make a (possibly
> implicit) similar declaration about every function

Perhaps our brains work in different ways here, but I think I would be
more likely to assume that, since the vast majority of Python function
declarations I see have no such annotations, that it's something
optional that's only rarely used.

I take your point about having something to look up in the docs.  In
the case of the built-in decorators (classmethod, etc.) looking up the
name of the decorator itself should provide an adequate starting
point, if the docs are written properly. But that wouldn't help
someone whose first introduction to decorators was by coming across a
user-defined one.

I still can't bring myself to like any of the keywords I've thought of
or seen suggested.

To serve the function of being up-lookable, it really needs to be a
new keyword, specific to this use, rather than re-using a generic one
like "as" or "is". But I can't think of one that doesn't put undue
emphasis on the mechanism, which I don't think would be helpful to
either newbies or experienced users. Newbies don't want to be swamped
with getting their brains around all the subtleties of how it works,
and experienced users don't want to have to think about it all the

Moreover, the mechanism is so general, and can be used to achieve such
a wide variety of effects, that the mechanism itself is really all
they have in common. So I don't think its' going to be *possible* to
find a single distinctive non-mechanism-related keyword that is truly
apt for all its uses.

By the way, there are already instances of syntax that people
frequently find difficult to look up, such as the * and ** arguments.
Maybe we could do with some kind of "explain" tool that you could
feed a snippet of code to and it would provide manual references
to all the syntactic features it contained?


   % pyexplain
   Welcome to the Python Syntax Explainer! What piece of code
   is puzzling you?
   >>>  def marmalade(self, x) [classmethod]:

   This is a Function Definition (see Python Language Reference
   section 7.5).

   The items enclosed in [...] are Function Decorators (see
   Python Language Reference section ?.?).


Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list