[PyKDE] QtCore.Qt and QtGui.Qt

Phil Thompson phil at riverbankcomputing.co.uk
Thu Mar 2 10:41:45 GMT 2006


On Thursday 02 March 2006 10:21 am, Sundance wrote:
> On Thu, Mar 02, 2006 at 09:46:03AM +0000, Phil Thompson wrote:
> > The short answer is that the Python objects are placed in the module
> > corresponding to the C++ library in which they are implemented.
>
> Hmm, meaning that this:
>
> ---[ Code snippet ]----------------------------------------------------
> from PyQt4.QtCore import Qt as Qt1
> from PyQt4.QtGui import Qt as Qt2
>
> if Qt1 is Qt2:
>   print "The Force is strong with that one."
> else:
>   print "Wow, we might be having a structural problem of sorts there..."
> -----------------------------------------------------------------------
>
> ... would actually not print out a cheap Star Wars statement regarding
> PyQt?

Correct - they are different objects, as you would expect them to be.

> Shouldn't the Qt namespace be common across all the modules? I
> understand that's the case with the C++ version, isn't it?

A C++ namespace doesn't have an implementation, it just contributes to name 
mangling. In Python they have to be implemented by something so there is no 
direct comparison.

Phil




More information about the PyQt mailing list