Best way to use globally format
Cecil Westerhof
Cecil at decebal.nl
Sun May 3 11:21:32 EDT 2015
I have a file where I used a lot of {0}, {1} and {2}. Most but not all
are changed to {0:.3E}, {1:.3E} and {2:.3E}. But when I want to change
the format I come in dependency hell.
I could do something like:
format = ':.3E'
fmt0 = '{0' + format + '}
fmt1 = '{1' + format + '}
fmt2 = '{2' + format + '}
and replace occurrences of:
'before {0} after'
with:
'before ' + fmt0 + ' after'
But that does not really make me happy. Is there a better way?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the Python-list
mailing list