Pipe in the "return" statement

Archard Lias archardlias at googlemail.com
Mon Jul 25 14:00:16 CEST 2011


I have come across something I don't really understand and would be
grateful if someone could shed some light into my understanding of it.

In the documentation of the Qt4 libs in the page regarding the
QAbstractTableModel you find, to make the table editable, the

Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
    if (!index.isValid())
        return Qt::ItemIsEnabled;

     return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;

Now I'm working with PySide, the Python bindings from Nokia and I
figured the
return in the function to be related with a parent
followed by the actual Flag that says: "yes the item, the index is
at, is actually editable". So translation of the C++ to Python would
be, and
it actually worked:

def flags(self, index):
    if not index.isValid():
        return Qt.ItemIsEnabled

    return super(self.__class__, self).flags(index) |

Still I dont get how I am supposed to understand the pipe and its task/
idea/influece on control flow, of:
return <statement> | <statement>

Thankful if you could help me with this.

Kind regards,
Archard Lias

More information about the Python-list mailing list