fixed list containment (indents) & whitespace

This commit is contained in:
David Goodger 2004-03-30 13:39:21 +00:00
parent 7a9247a8dc
commit c0bf347be9
1 changed files with 87 additions and 71 deletions

View File

@ -61,6 +61,7 @@ metaclasses, but using metaclasses is sufficiently obscure that there
is some attraction to having an easier way to make simple is some attraction to having an easier way to make simple
modifications to classes. modifications to classes.
Background Background
========== ==========
@ -73,15 +74,21 @@ the topic`_ on ``python-dev`` shortly after the conference,
attributing the bracketed syntax to an earlier proposal on attributing the bracketed syntax to an earlier proposal on
``comp.lang.python`` by `Gareth McCaughan`_. ``comp.lang.python`` by `Gareth McCaughan`_.
.. _syntactic support for decorators: http://www.python.org/doc/essays/ppt/python10/py10keynote.pdf .. _syntactic support for decorators:
.. _10th python conference: http://www.python.org/workshops/2002-02/ http://www.python.org/doc/essays/ppt/python10/py10keynote.pdf
.. _michael hudson raised the topic: http://mail.python.org/pipermail/python-dev/2002-February/020005.html .. _10th python conference:
.. _he later said: http://mail.python.org/pipermail/python-dev/2002-February/020017.html http://www.python.org/workshops/2002-02/
.. _gareth mccaughan: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=slrna40k88.2h9o.Gareth.McCaughan%40g.local .. _michael hudson raised the topic:
http://mail.python.org/pipermail/python-dev/2002-February/020005.html
.. _he later said:
http://mail.python.org/pipermail/python-dev/2002-February/020017.html
.. _gareth mccaughan:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=slrna40k88.2h9o.Gareth.McCaughan%40g.local
Class decorations seem like an obvious next step because class Class decorations seem like an obvious next step because class
definition and function definition are syntactically similar. definition and function definition are syntactically similar.
Design Goals Design Goals
============ ============
@ -109,7 +116,9 @@ The new syntax should
language-sensitive editors and other "`toy parser tools out language-sensitive editors and other "`toy parser tools out
there`_" there`_"
.. _toy parser tools out there: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org .. _toy parser tools out there:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1010809396.32158.python-list%40python.org
Proposed Syntax Proposed Syntax
=============== ===============
@ -128,6 +137,7 @@ Class decorators are defined in an analogous fashion::
class MyClass(base1, base2) [dec1, dec2, ...]: class MyClass(base1, base2) [dec1, dec2, ...]:
pass pass
Alternate Proposals Alternate Proposals
=================== ===================
@ -141,7 +151,8 @@ decorators across multiple lines, and the keyword "as" doesn't have
the same meaning as its use in the ``import`` statement. Plenty of the same meaning as its use in the ``import`` statement. Plenty of
`alternatives to "as"`_ have been proposed. :-) `alternatives to "as"`_ have been proposed. :-)
.. _alternatives to "as": http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=mailman.236.1079968472.742.python-list%40python.org&rnum=2&prev=/groups%3Fq%3Dpython%2Bpep%2B318%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3Dmailman.236.1079968472.742.python-list%2540python.org%26rnum%3D2 .. _alternatives to "as":
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=mailman.236.1079968472.742.python-list%40python.org&rnum=2&prev=/groups%3Fq%3Dpython%2Bpep%2B318%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm%3Dmailman.236.1079968472.742.python-list%2540python.org%26rnum%3D2
:: ::
@ -161,7 +172,8 @@ single decorator chosen from a restricted set. For short lists it
works okay, but for long list it separates the argument list from the works okay, but for long list it separates the argument list from the
function name. function name.
.. _Python Template Language: http://www.mems-exchange.org/software/quixote/doc/PTL.html .. _Python Template Language:
http://www.mems-exchange.org/software/quixote/doc/PTL.html
:: ::
@ -179,6 +191,7 @@ suggests nesting of namespaces that doesn't exist. The name ``foo``
would actually exist at the same scope as the using: block. Finally, would actually exist at the same scope as the using: block. Finally,
it would require the introduction of a new keyword. it would require the introduction of a new keyword.
Current Implementation Current Implementation
====================== ======================
@ -199,6 +212,7 @@ though without the intermediate creation of a variable named ``func``.
.. _patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff .. _patch: http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-3.diff
Examples Examples
======== ========
@ -211,7 +225,7 @@ some examples of use.
1. Define a function to be executed at exit. Note that the function 1. Define a function to be executed at exit. Note that the function
isn't actually "wrapped" in the usual sense. isn't actually "wrapped" in the usual sense.
:: ::
def onexit(f): def onexit(f):
import atexit import atexit
@ -225,7 +239,7 @@ some examples of use.
disappears enterprising programmers would have to be more creative disappears enterprising programmers would have to be more creative
to create more instances. (From Shane Hathaway on ``python-dev``.) to create more instances. (From Shane Hathaway on ``python-dev``.)
:: ::
def singleton(cls): def singleton(cls):
return cls() return cls()
@ -236,7 +250,7 @@ some examples of use.
3. Decorate a function with release information. (Based on an example 3. Decorate a function with release information. (Based on an example
posted by Anders Munch on ``python-dev``.) posted by Anders Munch on ``python-dev``.)
:: ::
def release(**kwds): def release(**kwds):
def decorate(f): def decorate(f):
@ -251,7 +265,7 @@ some examples of use.
4. Enforce function argument and return types. 4. Enforce function argument and return types.
:: ::
def accepts(*types): def accepts(*types):
def check_accepts(f): def check_accepts(f):
@ -282,9 +296,9 @@ some examples of use.
This is from a posting by Bob Ippolito on ``python-dev`` based on This is from a posting by Bob Ippolito on ``python-dev`` based on
experience with `PyProtocols`_. experience with `PyProtocols`_.
.. _PyProtocols: http://peak.telecommunity.com/PyProtocols.html .. _PyProtocols: http://peak.telecommunity.com/PyProtocols.html
:: ::
def provides(*interfaces): def provides(*interfaces):
""" """
@ -306,6 +320,7 @@ some examples of use.
Of course, all these examples are possible today, though without the Of course, all these examples are possible today, though without the
syntactic support. syntactic support.
Open Issues Open Issues
=========== ===========
@ -315,7 +330,8 @@ Open Issues
(search for ``PEP 318 - posting draft``) on their behalf in (search for ``PEP 318 - posting draft``) on their behalf in
``python-dev``. ``python-dev``.
.. _strong arguments: http://mail.python.org/pipermail/python-dev/2004-March/thread.html .. _strong arguments:
http://mail.python.org/pipermail/python-dev/2004-March/thread.html
Copyright Copyright