[Zope-Coders] unicode question

Brian Lloyd brian.lloyd@zope.com
Fri, 5 Oct 2001 10:25:39 -0400


> How much should we be supporting unicode in Zope at present?
> 
> In some code I'm writing for the ZCatalog API, I want to see whether an 
> argument is a string or a sequence.
> 
> My first thought was to use:
> 
>    if isinstance(names, types.StringType):
>        names=(names,)
> 
> However, this won't work if "names" happens to be a unicode string.
> 
> So, should I add two if clauses?
> 
>    if isinstance(names, types.StringType):
>        names=(names,)
>    if isinstance(names, types.UnicodeType):
>        names=(names,)


We are certainly trying to write in anticipation of more use of 
unicode wherever we can. A standard way that we do this in other
places is:

if type(ob) in (types.StringType, types.UnicodeType):
  ...



Brian Lloyd        brian@zope.com
Software Engineer  540.361.1716       
Zope Corporation   http://www.zope.com