Most efficient solution?

William Park opengeometry at yahoo.ca
Mon Jul 16 13:44:19 EDT 2001


On Mon, Jul 16, 2001 at 06:03:27PM +0200, Alex Martelli wrote:
> "Jay Parlar" <jparlar at home.com> wrote in message
> news:mailman.995289809.28477.python-list at python.org...
>     ...
> > for eachItem in A:
> >     if eachItem in B:
> >         A.remove(eachItem)
> >
> > Now, this will work fine,
> 
> Are you sure about that?  Normally, modifying the list
> you're iterating on does NOT work fine.

Good point.  Most of us knew what he meant, though.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc.




More information about the Python-list mailing list