<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 06/19/2017 05:36 PM, Christopher Probst wrote:<br>
<blockquote type="cite"
cite="mid:CABhWjnrRF-sMpP-94r8yuOkG7A=LyfHaHhVEjvJG3JCMXkJqMg@mail.gmail.com">
<div dir="ltr">Hi,
<div><br>
</div>
<div>I am loving the PyQt. I want to confirm that the operator
">>" QTextStream operator does not work in PyQt5. This
will not work:
<pre style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:11.4pt">file = QFile(<span style="color:rgb(0,128,128);font-weight:bold">"myfile.txt"</span>)
<span style="color:rgb(0,0,128);font-weight:bold">if </span>file.open(QIODevice.ReadOnly):
stream = QTextStream(file)
stream >> <span style="background-color:rgb(228,228,255)">value</span>
stream >> text >> <span style="background-color:rgb(228,228,255)">value</span></pre>
<pre style="color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:11.4pt"><span style="background-color:rgb(228,228,255)">
</span></pre>
What are the preferred ways to deserialize an QIODevice in
PyQt?</div>
<div><br>
</div>
<div>Thanks,<br>
Christopher<br>
</div>
</div>
</blockquote>
The rrshift and rlshift operators won't work like that with
QTextStream, no.<br>
<br>
I would go with using python's build in functionality for files
instead:<br>
<br>
with open("myfile.txt", "r") as my_file:<br>
value = my_file.read()<br>
<br>
See the python documentation for more:
<a class="moz-txt-link-freetext" href="https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files">https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files</a><br>
<br>
<br>
</body>
</html>