[Python-checkins] r60216 - in python/trunk: Lib/encodings/__init__.py Lib/optparse.py Misc/NEWS Parser/tokenizer.c

Guido van Rossum guido at python.org
Thu Jan 24 19:09:52 CET 2008


On Jan 24, 2008 3:34 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> If this is trying to define isbasestring differently depending on
> whether or not basestring exists, wouldn't it make more sense to put the
> def statement inside the try/except statement? Something like:
>
> try:
>      basestring
>      def isbasestring(x):
>          return isinstance(x, basestring)
> except NameError:
>      def isbasestring(x):
>          return (isinstance(x, types.StringType)
>                  or isinstance(x, types.UnicodeType))

Well, the first 'def' should be moved into the else clause of course.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-checkins mailing list