Using % locals() or .format(**locals()) not always a good idea. As an example, this could be a possible security risk if the string is retrieved from the localization database or it may contain user input and it mixes the program logic and translation, since you have to take care of the strings used in the program.
A good workaround is to limit the available rows. As an example, I have a program that stores some information about a file. All data objects have a dictionary like this:
myfile.info = {'name': "My Verbose File Name", 'source': "My Verbose File Source" }
Then, when the files are processes, I can do something like this:
for current_file in files: print 'Processing "{name}" (from: {source}) ...'.format(**currentfile.info)
leoluk
source share