.format vs. %

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jan 2 22:47:37 EST 2012


On 2012年1月02日 17:51:48 -0800, Rick Johnson wrote:
> You may find the format spec to be cryptic at first. Well, most find
> regexes cryptic also -- but would anyone recommend NOT using regexes
> just because of crypti-ness? I think not. It's a non-starter.

I would.
If you have a task that doesn't *need* a regular expression solution, 
don't use a regular expression.
For what it's worth, I like the syntax of % formatting. It's nice and 
simple and compact while still being readable. format() is more powerful, 
but when I don't need that power, I stick to % formatting.
-- 
Steven


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /