Say I have this piece of code, and I want to execute it on two separate dictionaries. How can I do this easily without writing the code twice? I guess i could def a small function and then pass each dict to it. Are there any better ways?
for key, value in self.mfiles.iteritems():
if key not in self.INPUT['extras']:
self.mfiles[key] = self.dirs['confdir'] + '/' + value
for key, value in self.nmfiles.iteritems():
if key not in self.INPUT['extras']:
self.nmfiles[key] = self.dirs['confdir'] + '/' + value
You can do this:
However, I think writing a small function is probably clearer.