[Python-Dev] PEP 318: Decorators last before colon/bakeoff (original) (raw)
Jewett, Jim J jim.jewett at eds.com
Thu Apr 1 13:42:34 EST 2004
- Previous message: [Python-Dev] Re: ANNOUNCE: 'goto' for Python
- Next message: [Python-Dev] PEP 318: Let's not give in to FUD
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Typically the suite (things indented after the colon) are all of the same type.
Josiah Carlson:
Funny, but this isn't the case with Python anywhere else; I can have functions, class and variable definitions inside any other suite.
I phrased that badly.
The statements following a suite are all interchangable from the suite's perspective. If not, then a second header clause (e.g. "else:") is added. If a particular expression is special, it comes before the ":" within the header. (x, y in "for x in y:")
Docstrings are arguably an exception, but they get away with it because they evaluate to themselves, without a side-effect. If you remove their special status, programs don't change their behavior. (Which is why optimized code can just remove them.)
Decorators behave differently from other statements, and this should be clear.
Everything in Guido's bakeoff meets this requirement. Option 2 might cause confusion with normal lists, which is why he also listed 2.a.
(2) Individually fine, but the tie between the list and def is week.
[d1, d2, d3]
def func (args):
pass
(2a) Also warns you that the list is strange, but doesn't say how.
*[d1, d2, d3]
def func (args):
pass
(2b) Explicitly relates the list to the def, but does add a keyword. On the other hand, adding this keyword makes it slightly less difficult to extend the syntax again, if that ever becomes desirable.
[d1, d2, d3] of
def func (args):
pass
-jJ
- Previous message: [Python-Dev] Re: ANNOUNCE: 'goto' for Python
- Next message: [Python-Dev] PEP 318: Let's not give in to FUD
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]