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

Douglas Alan doug at alum.mit.edu
Fri Jun 29 15:56:14 CEST 2007


"Chris Mellon" <arkanes at gmail.com> writes:

> You're arguing against explicit resource management with the argument
> that you don't need to manage resources. Can you not see how
> ridiculously circular this is?

No.  It is insane to leave files unclosed in Java (unless you know for
sure that your program is not going to be opening many files) because
you don't even know that the garbage collector will ever even run, and
you could easily run out of file descriptors, and hog system
resources.

On the other hand, in Python, you can be 100% sure that your files
will be closed in a timely manner without explicitly closing them, as
long as you are safe in making certain assumptions about how your code
will be used.  Such assumptions are called "preconditions", which are
an understood notion in software engineering and by me when I write
software.

|>oug



More information about the Python-list mailing list