[PyKDE] Writing with QTextStrem
Giovanni Bajo
rasky at develer.com
Wed Feb 9 14:09:37 GMT 2005
Eric Jardim <ericjardim at gmail.com> wrote:
> I was trying to do a simple write of a strings to a text file, but the
> "<<" does not work with Python like it do in C++.
>
> What is the corresponding way of doing that in PyQt:
>
> QFile file("file.txt");
> QTextStream ts(&file);
> ts << "My string" << "\n";
> file.close();
>
> I read somewhere that the "<<" operator was not implemented "yet", but
> I don't know if that assertion is still valid.
>
> Anyway, how would you guys do this kind of simple writing?
Why do you want to use QTextStream? What is the specific advantage compared
to, eg:
>>> f = file("file.txt", "w")
>>> print >>f, "My string"
?
--
Giovanni Bajo
More information about the PyQt
mailing list