[I18n-sig] Strawman Proposal: Smart String Test

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri, 9 Feb 2001 21:23:44 +0100

> So? Sometimes a temporary hack is the right thing to do. If you want to
> revive the types sig to figure out a hierarchical interface concept then
> go ahead. I trying to solve a very simple, localized and pervasive
> problem:
> type(foo)==type("")
> You proposed that we should handle it by having a tuple or list called
> StringTypes in the types module. I tried to make a solution that is more
> forward-thinking because we can bring in your interface hierarchy magic
> later.

I'm in favour of adding types.isstring. I know that I have added

  StringTypes = [types.StringType, types.UnicodeType]
except AttributeError:
  StringType = [types.StringType]

  if type(foo) in StringTypes:

into many places, and that I had considered suggesting
types.StringTypes as a standard feature. I did not provide a patch
since it won't help for programs that need to be backwards-compatible.

types.isstring won't help for backwards compatibility, either, but it
is enough simplification over the original test (type(foo) ==
type("")), and has a great chance of being forwards-compatible.