[Zope-Coders] unicode question
Casey Duncan
c.duncan@nlada.org
Fri, 5 Oct 2001 10:18:31 -0400
On Friday 05 October 2001 10:06 am, you wrote:
> > Or even this:
> >
> > 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'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?)
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)
That's a good point. A common base would sure make this more intuitive. How's
about:
stringbase? stringobject? or stringydingy? 8^)
/---------------------------------------------------\
Casey Duncan, Sr. Web Developer
National Legal Aid and Defender Association
c.duncan@nlada.org
\---------------------------------------------------/