On Fri, Jul 11, 2014 at 09:56:36AM -0700, Alex Kleider wrote:

> If the part between a "with" key word and the ":" that follows it is not 
> an expression (and therefore can not be protected from 'end of line' by 
> enclosure in parentheses,) what is it?

A bug in the parser.

And one which is now fixed. This is using Python 3.3:

py> with (open(
...             '/tmp/foo', 'w')) as f:
...     f.write("Hello")
...
5
py> 


Works fine, no \ line continuation needed.

The point about rules like "don't use \ line continuation" is not that 
that you should never ever ever under any circumstances break them. I've 
done every single one of the "Don't" rules, deliberately, not out of 
ignorance, except the "from module import *" inside a function. (I have 
done it at module level.) The point of such rules are to guide you 
towards better practice, away from poor practice, and to make you think 
good and hard before breaking the rules.



-- 
Steven
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to