Re: "with" statement in the python gio wrapper ?
- From: David Versmisse <david versmisse itaapy com>
- To: gvfs-list gnome org
- Subject: Re: "with" statement in the python gio wrapper ?
- Date: Tue, 26 May 2009 12:42:47 +0200
Le Tue, 26 May 2009 01:16:37 +0200,
Mike Rooney <mrooney ubuntu com> a écrit :
> On Mon, May 25, 2009 at 10:52 AM, Alexander Larsson
> <alexl redhat com> wrote:
> > On Fri, 2009-05-22 at 10:51 +0200, David Versmisse wrote:
> >> Hello,
> >>
> >> I don't know if i'm on the good mailing list, sorry if not.
> >>
> >> I have a question about the python wrapper of gio.
> >>
> >> Do you plan to use the new "with" statement with all the gio
> >> objects. By example:
> >>
> >> g_file = File('foo.txt')
> >> with g_file.replace('', False) as f:
> >> ....
> >>
> >> Naturally, it's just a question to organize our development.
> >>
> >> By advance, thank you for your answer, and thank you for your
> >> library!
> >
> > I don't know if any python developers are on this list, but i don't
> > see how your question affects the gio python code, it seems more
> > about python code that uses the python gio library.
> >
>
> Well, to get more than just a slightly nicer syntax including
> automatic and transparent locking/unlocking and opening/closing, the
> gio File class would have to explicitly support this by doing the
> right thing in __enter__ and __exit__, so perhaps that is what David
> was asking. http://effbot.org/zone/python-with-statement.htm and the
> PEP have useful info on this.
>
Yes, exactly, the gio File class and the others "I/O" classes
(GLocalFileInputStream, ...). With the implementation of GIO, the
construction of a File object (for example to read it) does not raise
any exception, It is raised when we try to use the "read" member
function. So, maybe, the good place to implement __enter__ / __exit__
is in the classes returned by the functions of File (read, replace, ...)
--
David Versmisse
Itaapy <http://www.itaapy.com> Tel +33 (0)1 42 23 67 45
9 rue Darwin, 75018 Paris Fax +33 (0)1 53 28 27 88
_______________________________________________
Itaapy mailing list
Itaapy ikaaro org
http://mail.ikaaro.org/mailman/listinfo/itaapy
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]