On Sat, 2012-06-09 at 14:52 +0200, Holger Berndt wrote:
> 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
> examples.
> 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()
I believe the Python read() on a stream calls read_all() and Python's
read_part() calls the streams read(). At least that is why my note's
say; which are for Python 2.x
Attachment:
signature.asc
Description: This is a digitally signed message part