Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89872
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.python |
| Subject | Best way to use globally format |
| Date | Sun, 03 May 2015 17:21:32 +0200 |
| Organization | Decebal Computing |
| Lines | 21 |
| Message-ID | <87wq0pk7pf.fsf@Equus.decebal.nl> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="1e75f8f7bcfe2945d0316cb03b0f6951"; logging-data="13451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IA5qIKh7qmU119bejIywV2s1f3MAGFsY=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| X-Homepage | http://www.decebal.nl/ |
| X-Face | "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E |
| Cancel-Lock | sha1:UYt0iT2AmGdARARxLgxKaD1M6o4= sha1:us9Ym5c65rrS+9scgLSW+5D0QTs= |
| Xref | csiph.com comp.lang.python:89872 |
Show key headers only | View raw
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