Reading from a GFile


I'm trying to read from a GFile, but can't figure out how to do it.
I neither found an answer in the tutorial, nor in PyGObject's tests or

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 =
>>> a = bytearray(20)
>>> s.read_all(a, 10, None)
(True, 5)
>>> a.decode("utf-8")
>>> a

Some tries along these lines also crashed the Python interpreter when
trying to access the bytearray, but I can't reproduce it reliably.


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