Breakdown of approaches to PEP318

Terry Reedy tjreedy at udel.edu
Sun Mar 28 23:15:41 CEST 2004


"Sean Ross" <sross at connectmail.carleton.ca> wrote in message
news:7vD9c.318$1A6.114130 at news20.bellglobal.com...
> Here's a breakdown of most of the syntax discussed re: PEP318 using an
> example from python-dev. There are probably several more (I've added
[10]).
> The example applies both function decoration and annotation.

Let me add two more based on a proposal I just posted to PyDev.

> # [5] function attribute dictionary
> def foo(self)[publish_to_web]:
>         {spark_rule:"DOC:= HEAD BODY FOOT",
>          url="/cgi-bin/directory/directory"}
>         "doc string"
>         body


# [5B]
def f(self)::
    "doc string"
    publish_to_web(foo)
    {spark_rule:"DOC:= HEAD BODY FOOT",
      url="/cgi-bin/directory/directory"}
    :
    body

> # [6]  @function_attribute = ...
> def foo(self)[publish_to_web]:
>         @spark_rule="DOC:= HEAD BODY FOOT"
>         @url="/cgi-bin/directory/directory"
>         "doc string"
>         body

# [6B]
def foo(self)::
    "doc string"
    publish_to_web(foo)
    spark_rule="DOC:= HEAD BODY FOOT"
    url="/cgi-bin/directory/directory"
    :
    body

> # [7] :function_attribute:...
> def foo(self)[publish_to_web]:
>         :spark_rule:"DOC:= HEAD BODY FOOT"
>         :url:"/cgi-bin/directory/directory"
>         "doc string"
>         body

#[7B] identical to [6B]

The essential idea is that definition-time code should be strictly
separated from run-time code with ':'.  If so, no new syntax is *necessary*
(though some can be considered).  Assignments in the def-block would be
interpreted much like in class bodies (which are also executed at def
time).

Terry J. Reedy








More information about the Python-list mailing list