Re: [Pyobjc-dev] Re: [ pyobjc-Bugs-679748 ] NSMutableString gets converted to Python string
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2003-02-03 22:21:03
|
On Monday, Feb 3, 2003, at 17:16 US/Eastern, Bob Ippolito wrote: > What about this: > class UnicodeNSStringWrapper(unicode): > def __new__(clazz, myNSString): > s = > unicode.__new__(somethingToConvertNSStringInstanceToPyUnicodeObject(myN > SString)) > s._objc = myNSString > return s > def __getattr__(self, attr): > try: > return getattr(self._objc, attr) > except: > raise AttributeError, '%r object has no attribute %r' % > (self.__class__.__name__, self._objc) > > It should do anything that unicode() will do, just like the str > subclass I posted a bit ago.. and you don't lose any of the NSString > functionality. Given that I have to write somethingToConvertNSStringInstanceToPyUnicodeObject() anyway, I'll do so first, plug it into this and see what happens. (This old had ObjC programmer sometimes has to be beaten around the head with the obvious elegant path that only Python can offer.) thanks! b.bum |