compare list

Ben Bush pythonnew at gmail.com
Tue Nov 15 06:45:03 EST 2005


On 11/15/05, Simon Brunning <simon.brunning at gmail.com> wrote:
>
> On 15/11/05, Ben Bush <pythonnew at gmail.com> wrote:
> > an error reported:
> > Traceback (most recent call last):
> > File
> >
> "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
> > line 310, in RunScript
> > exec codeObject in __main__.__dict__
> > File "C:\temp\try.py", line 8, in ?
> > from sets import Set as set
> > ImportError: cannot import name Set
> > >>>
>
> Works for me. You don't have a sets module of your own, do you? Try
> this, and report back what you see:
>
> import sets
> print sets.__file__
> print dir(sets)
>
> --
> Cheers,
> Simon B,
> simon at brunningonline.net,
> http://www.brunningonline.net/simon/blog/
>
 I found I named the following python file as sets.py, which brought the
problem (is that right?). i changed it to other name and it works.
But the logic output is wrong.
from sets import Set as set
lisA=[1,2,5,9]
lisB=[9,5,0,2]
lisC=[9,5,0,1]
def two(sequence1, sequence2):
set1, set2 = set(sequence1), set(sequence2)
return len(set1.intersection(set2)) == 2
print two(lisA,lisB)
False(should be true!)

--
Thanks!
Ben Bush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051115/464f08be/attachment.html>


More information about the Python-list mailing list