[PyKDE] Auto-connecting Slots

Giovanni Bajo rasky at develer.com
Sat Jan 28 15:35:35 GMT 2006


Andreas Pakulat <apaku at gmx.de> wrote:

>>> A decorator is just a function and needs to reside in a namespace.
>>> While I could put the signature() function in the global namespace,
>>> that would be dumb.
>>
>> You can put it within the QtCore namespace, but please consider that many
>> people *will* use "from QtCore import *", as it's the default way to make
>> the code similar to the C++ counterpart.
>
> Actually making the code _not_ similar to C++ version is the reason for
> me to use PyQt. Else I could just use C++.

Then you are using the wrong package. PyQt design is made to make the code
as much similar as possible to its C++ counterpart. Otherwise, there is room
for *big* changes if we were to make a Pythonic Qt API (using properties,
more pythonic syntax for window construction, for signal connections and
what not).


>> If Trolltech added a "signature()" function, people would complain.
>> Trolltech doesn't use standard C++ namespaces, but they have their own
>> namespace: they prefix every class name with uppercase Q, and every
>> function name with lowercase q.
>
> Could you read this again for yourself please? If TT always prefixes a
> "q", then why should they introduce signature()? They will most probably
> introduce qSignature, just as they switched from SIGNAL  to qSIGNAL (or
> was it QSIGNAL, just check the changes from 4.0 to 4.1).

That is exactly my point. I'm saying that Trolltech *is* being consistent
(and it's even fixing mistakes in consistencies which are years old).
Trolltech has its own namespace, which is made of symbols beginning with 'q'
(either uppercase or lowercase). This is why it *is* good practice to use
"from QtCore import *" in your Python code: you still get a "namespace" for
Qt symbols.

This is also why I'm complaining if PyQt adds a "signature" name in its
module: that *would* pollute my namespace. "pyqtSignature" as suggested by
Phil doesn't. And it doesn't risk to conflict with a future qSignature added
by TT.


>> This is why I think PyQt is going the wrong way if it starts
>> suggesting to explicitally use QtCore before everything and/or makes
>> it harder for people to use the "from QtCore import *" form.
>
> Actually signature is the only way according to TT naming rules, because
> it will assure that signature is always PyQt specific.
>
> BTW: I do like the naming/module/package scheme of PyQt4 more, than the
> one of PyQt3. I'm mostly using QtCore.<blah> instead of from QtCore
> import *, only classes I need really frequently are importet into the
> current namespace (from QtCore import QString for example).

Fine. I would hate code which is not consistent with itself like you're
doing, but hey.

I mostly dislike the packing scheme of PyQt4, but I see where it's coming
from, and as long as I'm allowed to use the "from QtCore import *" without
polluting the global namespace, it's still good. Adding "signature" would be
a serious problem.
-- 
Giovanni Bajo




More information about the PyQt mailing list