[Python-Dev] Questions about '@' in pep 318

Skip Montanaro skip at pobox.com
Fri Aug 6 20:58:22 CEST 2004


    Martin> In Python, things at the same indentation level all belong
    Martin> together.

I think the point is that the collection of @-decorators and the immediately
following function definition (which can be separated from each other by a
lot of white space or comments, btw) effectively form a single function
definition.  I don't believe there are any other syntactic constructs in
Python where the keyword introducing the construct ("def" in this case)
doesn't occur at the beginning of the construct.

Hmmm...  Now that I think about it, might you "lose" an @ in a comment block
since # and @ have more-or-less the same density?  | might not suffer from
that sort of confusion.

    # description of what decorator1 does
    # description of what decorator1 does
    # description of what decorator1 does
    @ decorator1
    # description of what decorator2 does
    # description of what decorator2 does
    # description of what decorator2 does
    @ decorator2
    # description of what func does
    # description of what func does
    # description of what func does
    def func(...):
        pass

vs. 

    # description of what decorator1 does
    # description of what decorator1 does
    # description of what decorator1 does
    | decorator1
    # description of what decorator2 does
    # description of what decorator2 does
    # description of what decorator2 does
    | decorator2
    # description of what func does
    # description of what func does
    # description of what func does
    def func(...):
        pass

Eh, maybe not.  Small point in any case, I'm sure.

Skip


More information about the Python-Dev mailing list