> > >>> import types > > >>> type("") is types.ListType > > False > > >>> type("") is types.StringType > > True > > >>> type([]) is types.StringType > > False > > >>> type([]) is types.ListType > > True > > This is even worse than an 'isinstance' check; it refuses even > subclasses of the types you accept, breaking polymorphism *and* > inheritance.
And also note the following comment in the types module of the standard library that was imported above: # StringTypes is already outdated. Instead of writing "type(x) in # types.StringTypes", you should use "isinstance(x, basestring)". But # we keep around for compatibility with Python 2.2. -- http://mail.python.org/mailman/listinfo/python-list