Python's "only one way to do it" philosophy isn't good?

Paul Rubin http
Tue Jun 26 19:10:42 CEST 2007


Andy Freeman <anamax at earthlink.net> writes:
> Compare that with what a programmer using Python 2.4 has to do if
> she'd like the functionality provided by 2.5's with statement.  Yes,
> with is "just syntax", but it's extremely useful syntax, syntax that
> can be easily implemented with lisp-style macros.

Not really.  The with statement's binding targets all have to support
the protocol, which means a lot of different libraries need redesign.
You can't do that with macros.  Macros can handle some narrow special
cases such as file-like objects, handled in Python with
contextlib.closing.

That said, the with statement was missing from Python for much too
long, since users were happy to rely on reference counting.



More information about the Python-list mailing list