Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89872
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Best way to use globally format |
| Date | 2015-05-03 17:21 +0200 |
| Organization | Decebal Computing |
| Message-ID | <87wq0pk7pf.fsf@Equus.decebal.nl> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Best way to use globally format Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 17:21 +0200 Re: Best way to use globally format Peter Otten <__peter__@web.de> - 2015-05-03 18:16 +0200 Re: Best way to use globally format Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-03 17:32 +0100
csiph-web