Would you say it's better to first determine what the duplicates are, compile a list, then remove them after the iteration is complete?

On Jul 1, 2013, at 5:05 PM, Dirk Thomas <notifications@github.com> wrote:

> In src/rosdep2/platforms/osx.py:
> 
> > @@ -141,3 +143,17 @@ def get_install_command(self, resolved, interactive=True, reinstall=False):
> >          else:
> >              return [['brew', 'install', p] for p in packages]
> >  
> > +    def remove_duplicate_dependencies(self, packages):
> > +        # find all dependencies for each package
> > +        for p in packages:
> > +            sub_command = ['brew', 'info', p]
> > +            output = subprocess.Popen(sub_command, stdout=subprocess.PIPE).communicate()[0]
> > +            match = re.findall("Depends on: (.*)", output)
> > +            if match:
> > +                dependencies = re.split(',', match[0])
> > +                for d in dependencies:
> > +                    d = d.strip()
> > +                    # remove duplicate dependency from package list
> > +                    if(d in packages):
> > +                        packages.remove(d)
> I don't think it is a good idea to remove items from the packages list while iterating over it.
> 
> —
> Reply to this email directly or view it on GitHub.