Re: Reading from a GFile



On Sa, 09.06.2012 11:05, Adam Tauno Williams wrote:

>On Sat, 2012-06-09 at 14:52 +0200, Holger Berndt wrote: 
>> Here is what I'm trying:
>> $ echo "Test" > /tmp/tst
>> $ python3
>> Python 3.2.1 (default, Jul 11 2011, 18:54:42) 
>> [GCC 4.6.1 20110627 (Red Hat 4.6.1-1)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> from gi.repository import Gio
>> >>> f = Gio.file_new_for_commandline_arg("/tmp/tst")
>> >>> s = f.read(None)
>> >>> a = bytearray(20)
>> >>> s.read_all(a, 10, None)
>> (True, 5)
>> Some tries along these lines also crashed the Python interpreter when
>> trying to access the bytearray, but I can't reproduce it reliably.
>
>handle = gio.file('test.txt')
>stream = handle.read()
>stream.read()

This looks like PyGtk. I was talking about PyGObject, and indeed, I can
get it to work in PyGtk but not in PyGObject. Sorry if I wasn't clear.

Holger

Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]