tjreedy at udel.edu
Wed Jan 14 12:20:08 CET 2009
Carl Johnson wrote:
> From the department of doomed ideas:
> data = f.read() with open("file.txt") as f
> Has the idea of a with-expression already been preemptively shot down?
> I guess the objection is that the above could easily be rewritten as
> data = read_and_close("file.txt")
> if one defines the appropriate function. The counter-objection is that
> why do I need to write a micro-function when the with-statement already
> does what I want, except it takes up two lines when it would still be
> clear as one line. But then the counter-counter-objection is that you
> can write
> with open("file.txt") as f: data = f.read()
> today. To which the counter-counter-counter-objection is, yeah, but that
> looks cluttered and ugly in a way that the first example doesn't...
> Except the first example is sort of cluttered.
> I dunno, what do other people think about this? Doomed or super-doomed?
Twisted and super-doomed.
More information about the Python-ideas