[PyKDE] Null pointer test
Gordon Tyler
gordon at doxxx.net
Thu Oct 17 21:49:00 BST 2002
Ingo Krabbe wrote:
> When I want to go a level up I do:
>
> parent = parent.parent()
>
> But this only works if we aren't at the root node since a QListViewItem
> isn't a QObject but opens an own base class. So
>
> parent.parent() would give NULL in C++.
>
> What's returned in pyqt here ?
The Python equivalent of C/C++'s NULL is None. So you would do something
like this:
parent = parent.parent()
if not parent is None:
# do stuff with parent
None evaluates to false in an if expression so you could shorten it to:
if parent:
# do stuff with parent
Ciao,
Gordon
More information about the PyQt
mailing list