Re: [PyKDE] Coerce QString to unicode or str?

2005-10-10 Thread Nigel Stewart



That raises two questions - (1) would it be desirable for
Python to quietly convert QStrings to unicode as needed,
and (2) is it technically possible in Python 2.4, 3.x?


It's a SIP limitation that will be fixed in the next version (in fact a 
partial implementation will be in tonight's snapshot).


Phil,

Let us know when you think it's ready - it's about
time we migrated to the latest Sip/PyQt here.

Nigel

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Coerce QString to unicode or str?

2005-10-10 Thread Phil Thompson
On Monday 10 October 2005 5:22 pm, Nigel Stewart wrote:
 That raises two questions - (1) would it be desirable for
 Python to quietly convert QStrings to unicode as needed,
 and (2) is it technically possible in Python 2.4, 3.x?
 
  It's a SIP limitation that will be fixed in the next version (in fact a
  partial implementation will be in tonight's snapshot).

 Phil,

 Let us know when you think it's ready - it's about
 time we migrated to the latest Sip/PyQt here.

The next official release won't be for some time as I'm making lots of changes 
for PyQt4.

Phil

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] Coerce QString to unicode or str?

2005-10-09 Thread Phil Thompson
On Friday 07 October 2005 5:42 pm, Nigel Stewart wrote:
 PyQt happily converts python strings and unicode strings
 into QString arguments for Qt API calls.  That's very
 convenient.

 In Python, string and unicode objects can be mixed,

 and are coerced as needed:
   print type(hello + unicode(world))

 type 'unicode'

   print type(unicode(hello) + world)

 type 'unicode'

 What would be nice, would be similar handling for

 QString:
   print type(hello + qt.QString(world))

 Exception: cannot concatenate 'str' and 'qt.QString' objects

   print type(unicode(hello) + qt.QString(world))

 Exception: coercing to Unicode: need string or buffer, qt.QString found

 Python provides 2.4 provides coersion for numeric
 types, but is deprecated.  The intention is that
 methods should explicitly deal with whatever type
 of argument is given, rather than depend on coersion.

  This section used to document the rules for coercion.
   ... In Python 3.0, coercion will not be supported.

 http://www.python.org/doc/2.4.2/ref/coercion-rules.html

 That raises two questions - (1) would it be desirable for
 Python to quietly convert QStrings to unicode as needed,
 and (2) is it technically possible in Python 2.4, 3.x?

 A sip-based solution might be to provide SIP_PYUNICODE or
 SIP_PYSTRING as alternative return types to QString.
 But, I think it might be disruptive for the PyQt bindings
 to be taken in this direction...

It's a SIP limitation that will be fixed in the next version (in fact a 
partial implementation will be in tonight's snapshot).

Phil

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde