[Python-Dev] PEP 318 - generality of list; restrictions on

elements ([original](http://mail.python.org/pipermail/python-dev/2004-March/043043.html)) ([raw](?raw))

Skip Montanaro skip at pobox.com
Wed Mar 10 15:04:02 EST 2004


Phillip> The way I see it, left-to-right helps reading what's happening
Phillip> to the function.  For example:

Phillip> def foo(cls,...) [contract(blah), classmethod]:
Phillip>      ...

Phillip> clearly says that a contract wrapper is being applied to foo,
Phillip> and then it is being made a classmethod.

On the off-chance that a default arg initializer has side effects, left-to-right also guarantees that the side effects take place before the decorator expression is evaluated:

i = I(...)

def foo(a=i.func(...), b, c) [i.w1(...), w2]:
    ...

Evaluating i.func(...) might have some effect on the execution of i.w1(...). I don't claim that's necessarily a good property to rely on, but if reading order matches evaluation order it makes for fewer surprises.

Phillip> If the order were the other direction, it would force you to
Phillip> read right-to-left in order to know what's going to happen to
Phillip> the function.

Phillip> So, I vote for left-to-right on the grounds of "readability
Phillip> counts".  :)

+1.

Skip



More information about the Python-Dev mailing list