Code style query: multiple assignments in if/elif tree

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Mar 31 20:57:01 EDT 2014


On Tue, 01 Apr 2014 10:12:38 +1100, Chris Angelico wrote:
[...]
>> I agree with others that triple-quoted strings are best reserved for
>> string literals (including docstrings), not comments.
> 
> Fair enough. I can't remember where (or when!) it was that I learned
> triple-quoted strings were appropriately abused as comments, so I've
> just done a quick re-layout into hash comments.

Probably here :-)

But note the emphasis on "abused". The only time I would use triple-
quoted strings as comments is if I wanted to quickly comment out a 
section of code:

do_this()
do_that()
'''
def do_something_else():
    """Docstring"""
    pass
do_something_else()
'''
do_more()
do_less()


sort of thing. (Note the cunning use of ''' instead of """.) But I 
wouldn't leave it like that in production code.

It's *tempting* to use """ to mark out a large block of text, and I 
wouldn't say that doing so was wrong, but it's a bit different, and 
programmers are very like cats: they don't like different.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/



More information about the Python-list mailing list