[Python-Dev] Python FAQ: Why doesn't Python have a "with" statement?

Nick Coghlan ncoghlan at gmail.com
Sun Jun 15 07:14:41 CEST 2008


Cesare Di Mauro wrote:
> I agree: Python's with statement does have a completely different
> meaning of the same Pascal & Co 's statement.
> 
> However, I don't agree with the FAQ on this point. I think that a
> Pascal-like with statement can be achieved, even with a dynamic
> language such as Python, and in a simple way.

It isn't that a Pascal-with-style statement can't be achieved, it's that 
it is pointless syntactic sugar in Python. Just use o = 
long_complicated_object_name instead.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list