[Zope-Coders] unicode question
Brian Lloyd
brian.lloyd@zope.com
Fri, 5 Oct 2001 10:45:42 -0400
> > if type(names) in (types.StringType, types.UnicodeType):
> > names=(names,)
>
> No!
>
> > Although, I'm sure using isinstance is better than comparing types.
>
> Indeed. Using isinstance is VERY important with an eye on migrating
> to new-style types/classes in Python 2.2: the argument could be a
> subclass of types.StringType, and then tests using "type(x) is T" or
> "type(x) in T" will fail. The isinstance(x, T) test will succeed
> though.
I remembered that right after I hit "send" :( Bad, bad me. This is
actually going to require a seek-and-destroy effort in Zope, as this
no-no is used in a number of places.
> (I'm still thinking about whether to provide a common base for str and
> unicode; the more I see this kind of examples, the more I think there
> should be one. But what to call it? abstractstring? String? string?)
StringThing? :)
Brian Lloyd brian@zope.com
Software Engineer 540.361.1716
Zope Corporation http://www.zope.com