A decorator syntax not yet mentioned (I think!)

Carl Banks imbosol at aerojockey.invalid
Thu Aug 12 04:31:58 EDT 2004


Peter Hansen wrote:
> 
> 
> Carl Banks wrote:
> 
>> steven.bethard at gmail.com (Steven Bethard) wrote in message news:<d11dcfba.0408111433.43f025f8 at posting.google.com>...
>> 
>>>I know there were complaints before about this sort of indentation,
>>>but I couldn't find them in python-dev and the comments in the wiki
>>>don't discuss this in any detail.  Can anyone tell me why this
>>>indentation syntax was dispreferred?  Specifically, I'm interested in
>>>why this is so drastically different from the other paired blocks:
>>>if/elif/else, try/except, try/finally, etc. 
>> 
>> One thing that's different is that, in all those cases, the second
>> block has a keyword that can't appear alone.  You can't have an except
>> without a try, or an else without an if, but you could have a def
>> without a decorate.
> 
> Is this merely a pedantic argument (not sure I use "pedantic" correctly)
> or is this an argument based on presumed difficulties in implementing
> the idea?

Pedantic.


> I ask because I'm not sure the issue matters to anyone writing
> or reading the code.  It certainly wouldn't bother me that
> with if/else it's the first part that's required, while with
> decorate/def it's the second part.

Well, the only thing is, whenever you see a def statement, you don't
know if it's decorated right away, so you have to expend one or two
extra ergs of energy to look above it and see if it is.  (And let's
face it, with the dozens and dozens of decorators that will be applied
to each and every function, it might be a couple screens up. :)

To me, it's totally irrelevant.

I think it would bother some other people, though.  I've seen the very
same argument used against a do...while statement.  (The do...while
statement didn't bother me either, although ideally I'd prefer do to
replace try in try...finally.)


-- 
CARL BANKS                      http://www.aerojockey.com/software
"If you believe in yourself, drink your school, stay on drugs, and
don't do milk, you can get work." 
          -- Parody of Mr. T from a Robert Smigel Cartoon



More information about the Python-list mailing list