<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.14">
<TITLE>operator module isSequenceType with builtin set produces False</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">X-Replace-Address: mark.ignorethisbit.english@xxxrbccmxxx.ignorethisbittoo_and_removethosepreceding_xxxs_.com</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">This wasn't what I was expecting, so I thought I'd ask those more knowledgeable, which is pretty much everybody.</FONT>
<BR><FONT SIZE=2 FACE="Arial">Same result on Python 2.3.5 and Python 2.5.1 installed from python.org binaries on Windows XP.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">>>> try: set</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> except NameError: from sets import Set as set</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> class myset_fails(set): pass</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> class myset_works(set):</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> def __getitem__(self): pass</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> s = set()</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> fails = myset_fails()</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> works = myset_works()</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> import operator</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> operator.isSequenceType(s) #Not what I expected</FONT>
<BR><FONT SIZE=2 FACE="Courier New">False</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> operator.isSequenceType(fails) #Not what I expected either</FONT>
<BR><FONT SIZE=2 FACE="Courier New">False</FONT>
<BR><FONT SIZE=2 FACE="Courier New">>>> operator.isSequenceType(works) #A hint at what isSequenceType does ?</FONT>
<BR><FONT SIZE=2 FACE="Courier New">True</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Are sets not sequences ? I didn't think the</FONT> <FONT SIZE=2 FACE="Courier New">isSequenceDisclaimer</FONT><FONT SIZE=2 FACE="Arial"> gave false negatives.</FONT>
<BR><FONT SIZE=2 FACE="Arial">See Raymond Hettinger's post here too:</FONT>
<BR><A HREF="http://groups.google.co.uk/group/comp.lang.python/tree/browse_frm/thread/bd04db20cc1f23bb/36f1f48bb7be1e4b?hl=en&rnum=1&q=set+isSequenceType&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Fbd04db20cc1f23bb%2F0454f5debc01c20d%3Fhl%3Den%26lnk%3Dgst%26q%3Dset%2BisSequenceType%26#doc_0454f5debc01c20d"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">http://groups.google.co.uk/group/comp.lang.python/tree/browse_frm/thread/bd04db20cc1f23bb/36f1f48bb7be1e4b?hl=en&rnum=1&q=set+isSequenceType&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Fbd04db20cc1f23bb%2F0454f5debc01c20d%3Fhl%3Den%26lnk%3Dgst%26q%3Dset%2BisSequenceType%26#doc_0454f5debc01c20d</FONT></U></A></P>
<P><FONT SIZE=2 FACE="Arial">Although there are suggestions that it means simply that you're headed in the wrong direction design wise:</FONT>
<BR><A HREF="http://www.mail-archive.com/python-dev@python.org/msg11576.html"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.mail-archive.com/python-dev@python.org/msg11576.html</FONT></U></A>
</P>
<P><FONT SIZE=2 FACE="Arial">but then why have</FONT> <FONT SIZE=2 FACE="Courier New">isSequenceType</FONT><FONT SIZE=2 FACE="Arial"> at all ?</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">Not particularly vital. Just implementing</FONT> <FONT SIZE=2 FACE="Courier New">__str__</FONT> <FONT SIZE=2 FACE="Arial">on some class and if one of the members was a sequence</FONT>
<BR><FONT SIZE=2 FACE="Arial">I was going to format that bit of data in brackets.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Mark</FONT>
</P>
<pre>______________________________________________________________________
This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential.
Unauthorised use or disclosure is prohibited.If you receive This e-mail in error, please advise immediately and delete the original message.
This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message.
</pre></BODY>
</HTML>