[PyQt] Where is the "<<" insertion overload done?

Dmitry Shachnev mitya57 at ubuntu.com
Tue Nov 25 06:48:30 GMT 2014


Hi,

On Tue, Nov 25, 2014 at 8:17 AM, David Cortesi <davecortesi at gmail.com> wrote:
> I've been happily using the "<<" insertion operator to write to QTextStreams
> for some time now, and only recently realized that "<<" is binary shift left
> in standard Python. Well, not so much realized, as had it rubbed in my face
> by PyLint, which warns that "stream << string" is an expression whose value
> is not being assigned.
>
> Somehow a QTextStream (derived) object arranges an overloaded meaning of
> ".write()" onto this operator. But where/how is the overload done?

Just like any other operator overload. Search for 'lshift_slot' in sip code.

Simple example code (in Python) if you want to do this yourself is attached.

--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 220 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141125/e6e87f84/attachment.py>


More information about the PyQt mailing list