Re: [Pyobjc-dev] Auto bridging instances by conversion
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-02-03 19:19:58
|
Bob Ippolito wrote: > > Not converting can also be problematic: What if you pass the > > NSString to an extension-function that expects a string (like > > open), unless these get changed to also accept NSStrings you'll > > have to perform manual conversion from NSString to a python string. > > Say NSString acts like 100% like UserString (i.e. implements __str__ > and such), wouldn't PyArg_ParseTuple(AndKeywords) do The Right Thing? I have no idea how well this can work, but UserString seems to be a pain: Python 2.3a1 (#106, Feb 2 2003, 19:33:52) [GCC 3.1 20020420 (prerelease)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> from UserString import UserString >>> s = UserString("lalalala") >>> s 'lalalala' >>> repr(s) "'lalalala'" >>> open(s) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: coercing to Unicode: need string or buffer, instance found >>> re.match("la", s) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.3/sre.py", line 132, in match return _compile(pattern, flags).match(string) TypeError: expected string or buffer >>> Just |