[XML-SIG] Writing DOM-neutral code
Fred L. Drake, Jr.
fdrake@acm.org
Wed, 5 Dec 2001 17:41:13 -0500
Juergen Hermann writes:
> On Wed, 05 Dec 2001 15:36:59 -0500, Rich Salz wrote:
>
> >+ if type(a) == type({}): return a.values()
>
> Totally unrelated: don't do this any more, use isinstance(a, type({})).
Type objects should never be compared using ==; use "is" if you must
compare type objects.
Juergen's formula for testing the type of an object is preferred to
checking that an object has a specific type. If you can tolerate a
Python 2.2-ism, it can be spelled more simply in the case of a
dictionary:
isinstance(a, dict)
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation