Re: [Pyobjc-dev] PyObjC- vs. Python Unicode
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-07-02 11:25:50
|
On Wednesday, Jul 2, 2003, at 13:15 Europe/Amsterdam, Dinu Gherman wrote: > Hi, > > I'm taking a Unicode string out of an NSTextField, but its type seems > to be <type 'objc.pyobjc_unicode'>, not quite like <type 'unicode'> > which I'd like to feed into a regular expression using the re module > (with Unicode mode). Now I'm getting a TypeError for re.compile. Arghhh... we cannot use the plain unicode to represent ObjC strings because you may want to directly access the ObjC string, maybe because it is a mutable string or because you want to use one of the gazillion methods that have no direct python equivalent. We decided to subclass the unicode type to make it easier to use ObjC strings in python: Passing them to extension modules expecting strings or unicode objects "just works". SRE doesn't work because it tests types using '==' instead of 'isinstance'. IMHO this is a bug in SRE. > > Is their some canonical mechanism to convert to the true Python Uni- > code type? unicode(value) Ronald |