[XML-SIG] setAttribute DOM question-newbie

Patrick K. O'Brien pobrien@orbtech.com
Thu, 15 Nov 2001 09:09:03 -0600


How is this cleaner? I would have used the suggested code myself, but now
you've got me worried. Is an isinstance(s, StringType) check faster than
always doing str()? What am I overlooking? What makes it cleaner?

Thanks.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: xml-sig-admin@python.org [mailto:xml-sig-admin@python.org]On Behalf Of
Fred L. Drake, Jr.
Sent: Thursday, November 15, 2001 9:51 AM
To: Thomas B. Passin
Cc: xml-sig@python.org
Subject: Re: [XML-SIG] setAttribute DOM question-newbie


Thomas B. Passin writes:
 > >             if type(s) != type(""):
 > >                 s = `s`
 >
 > I would have used
 >      s=str(row[i])
 >
 > A bit simpler...

  Simpler, but the semantics are different.  A cleaner approach might
be:

        if not isinstance(s, StringType):
            s = `s`


  -Fred

--
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation


_______________________________________________
XML-SIG maillist  -  XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig