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

Andy Freeman anamax at earthlink.net
Tue Jun 26 17:54:21 EDT 2007


On Jun 26, 10:10 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Andy Freeman <ana... 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.

Yes really, as the relevant PEP shows.  The "it works like" pseudo-
code is very close to how it would be defined with lisp-style macros.

> The with statement's binding targets all have to support
> the protocol, which means a lot of different libraries need redesign.

That's a different problem, and it's reasonably solvable for anyone
who wants to use the roll-your-own with while writing an application
running under 2.4.  (You just add the relevant methods to the
appropriate classes.)

The big obstacle is the syntax of the with-statement.  There's no way
to define it in python with user-code.




More information about the Python-list mailing list