[XML-SIG] setAttribute DOM question-newbie

Patrick K. O'Brien pobrien@orbtech.com
Thu, 15 Nov 2001 10:32:31 -0600


Ah, yes. I never use backticks, so I always forget if they do a str() or a
repr(), which is why I never use them. Vicious cycle. And I guess it's never
too soon to start preparing for 2.2 and the type changes. Thanks for the
reminder.

---
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 11:04 AM
To: pobrien@orbtech.com
Cc: Thomas B. Passin; xml-sig@python.org
Subject: RE: [XML-SIG] setAttribute DOM question-newbie

  Always doing str() has different semantics than this or the original
fragment:

>>> class MyObject:
...     def __str__(self):
...         return 'ImaCoolObject'
...
>>> s = MyObject()
>>> str(s)
'ImaCoolObject'
>>> `s`
'<__main__.MyObject instance at 0x8127104>'

  My assertion about code cleanliness was in comparison to using
type(s) != StringType; using isinstance makes more sense when s might
be a subclass of StringType, which will be a possibility in Python
2.2.  In this context, it may not make any difference, but clean
coding gains from consistency.


  -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