ext Marcelo Lira wrote:
Maybe on the same subject: would it be appropriate to add to the same
PSEP a implementation for the with() protocol for QFile? See
http://docs.python.org/reference/datamodel.html#context-managers for
the details. It could allow something like:
with QFile("/tmp/file.txt") as f:
data = f.readAll()
...
the with statement is available since python2.5 (but not enabled on it
by default; needs the "from __future__ import with_statement"; on
python2.6 and newer it is already default).
Great idea. :)
I'm somewhat hesitant on having this in the same PSEP, as I believe the
issues are only partially related. It might be safer to have this as a
separate PSEP.
Regarding the content, another issue here is that you argued that QFile
should not open the file automatically, yet you are doing that right
here. At a minimum, probably the syntax would have to be something like
with QFile("/tmp/file.txt").open(QFile.ReadOnly) as f:
...
Or are you suggesting a default __enter__ method that would open the
file readonly?
Cheers,
ma.
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside