[PyKDE] PyQt4 and Python2.3

Torsten Marek shlomme at gmx.net
Thu Jul 6 10:47:34 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Pakulat wrote:
> On 06.07.06 10:37:11, Torsten Marek wrote:
>> Andreas Pakulat wrote:
>>> PyQt4 entered Debian/Sid today and I had to try wether my apps also work
>>> under the "system python" now. Unfortunately they don't and I'd just
>>> like a confirmation that this is "intentional". Debian/Sid still uses
>>> python2.3 as standard system python and that one doesn't know decorators
>>> yet, as it seems. So if decorators only work with Python 2.4, this
>>> should be stated in the docs regarding auto-connection and also I think
>>> a note should appear in the README.
>>>
>>> If decorators should work with python2.3, I'd like to why this doesn't
>>> work:
>>>
>>> andreas at morpheus:~/projects/xpathevaluator>PYTHONPATH=$PWD /usr/bin/python2.3 xpathevaluator/xpathevaluator.py
>>> Traceback (most recent call last):
>>>   File "xpathevaluator/xpathevaluator.py", line 57, in ?
>>>     sys.exit(run())
>>>   File "xpathevaluator/xpathevaluator.py", line 35, in run
>>>     from xpathwidget import XPathWidget
>>>   File "/home/andreas/projects/xpathevaluator/xpathevaluator/xpathwidget.py", line 198
>>>     @pyqtSignature("on_fileButton_clicked()")
>>>     ^
>>> SyntaxError: invalid syntax
>> decorators don't work with Python 2.3, they are a Python 2.4 feature.
> 
> That's what I guessed already...
> 
>> With Python 2.3, you need to use the decorators the old way, like staticmethod
>> was used etc.
> 
> Can you give me an example for this (via PM if you want to)? Would it
> then be possible to do something like
> 
> if python_version==2.4:
>   @pyqtSignature..
> else:
>   <the older decorator-stuff>
> def the_slot():

Hi,

no, that doesn't work, since it's a new syntax feature rather than a new
function. You'd need a real preprocessor to achieve something like that.
When you want your program to work with both 2.3 and 2.4, you'll need to use

def the_slot():
    ...
the_slot = pyqtSignature("on_fileButton_clicked()")(the_slot)

That's the way decorators with arguments are handled by Python.

best,

Torsten

- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFErNw2fMVFHqJEyFgRAob6AKCmLsA6e4THH9V0hRedEQmw7jochACeI1y5
hcWs+W1uq/N92fIcdP0rVF0=
=s/A8
-----END PGP SIGNATURE-----




More information about the PyQt mailing list