[Python-ideas] Line continuations with comments

Andrew Barnert abarnert at yahoo.com
Wed May 22 18:05:10 CEST 2013


On May 22, 2013, at 7:54, random832 at fastmail.us wrote:

> On Wed, May 22, 2013, at 10:31, Mike Graham wrote:
>> With changes a while back making backslash continuations never strictly
>> necessary,
> 
> Someone pointed out an example a while back of them being necessary
> (except for being vacuously unnecessary because you can just make an
> arbitrarily long physical line): multiple values in a with statement.

Well, you can always break within each expression, adding extra parens within the expression if necessary.

But often, this looks even worse than backslashes.

    with closing(NSWhyDoesAppleUseSuchLongNames(
    NSLongNamedConstant)) as thing1, closing(
    NSAnotherLongFunction(
        NSAnotherLongConstant)) as thing2

I may have got this wrong because I'm typing on a phone, but you get the idea. This is legal, and it follows PEP8, and it doesn't require a backslash. But it's horrible.

Another alternative is to bind all those silly PyObjC names to shorter names--but then, when you're reading the code, you can't immediately tell what it does. 

I don't _always_ have to use backslashes in code using ridiculous names like this to make it readable, but sometimes they are the best solution.

So, even though I don't know that they're _necessary_, I still don't want backslashes deprecated.

But I also don't want them expanded.


More information about the Python-ideas mailing list