[Python-checkins] python/dist/src/Lib urllib.py,1.143,1.144
Fred L. Drake, Jr.
fdrake@acm.org
2002年5月24日 14:14:19 -0400
gvanrossum@users.sourceforge.net writes:
> + if hasattr(types, "UnicodeType"):
> + def _is_unicode(x):
> + return isinstance(x, unicode)
> + else:
> + def _is_unicode(x):
> + return 0
> +
Is this preferable to:
try:
unicode
except NameError:
def _is_unicode(x):
return 0
else:
def _is_unicode(x):
return isinstance(x, unicode)
I've generally been using the later for feature tests; should I be
doing it differently?
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation