[PyKDE] Auto-connecting Slots
Patrick K. O'Brien
pobrien at orbtech.com
Sun Jan 29 13:25:04 GMT 2006
Giovanni Bajo wrote:
> Gerard Vermeulen <gerard.vermeulen at grenoble.cnrs.fr> wrote:
>> from PyQt4.QtCore import *
>> from PyQt4.QtCore import signature as pyqtSignature
>> import signature from signature
> Not a solution, you still have "signature" in the global namespace.
>> I understand that you like to take an unrecommended shortcut and
>> pollute the global namespace (Q-, q-prefix or not), but it is no
>> reason to make life harder for people who don't.
> The Q prefix *is* a namespace.
I would not call that a namespace in Python. It is a prefix. Nothing
more, nothing less. When you "import *" lots of things get added to the
local namespace. When you "import wx", for example, all wxPython
objects reside within the wx namespace instead of getting added to the
local namespace. That is a significant difference.
> It's the way namespaces have always worked way
> before we were using languages with explicit syntax for namespaces, and the way
> it works in C++ for Qt. Then, if you want to double your namespace by prefixing
> an unneeded QtCore in front of it, and making your source code harder and
> slower to read, that's your choice. The fact that in Python modules are
> namespaces doesn't mean that one has to blindly use them as namespaces even
> when not necessary. Again, I have *never* seen Python code using PyOpenGL with
> the module as a namespace (GL.glBegin), so I just can't see why it should be
> any different for Qt.
If we're going to use other large projects as examples then surely
wxPython is a better one. They spent the past year or two moving from this:
from wx import *
button = wxButton(...)
button = wx.wxButton(...)
button = wx.Button(...)
Google for details of the bloody battle (I'm the one with the arrows in
my back). FWIW, while wxPython initiated this move, wxWidgets (C++) has
since followed suit. So maybe your way is how it has historically been
done in C++, but not everyone agrees that is still the best way. :-)
Patrick K. O'Brien
More information about the PyQt