[Python-3000] Please don't kill the % operator...

skip at pobox.com skip at pobox.com
Thu Aug 16 21:52:21 CEST 2007


 STeVe> I honestly can't see the point of keeping this::
 >>>> '%-10s bought %02i apples for %3.2f' % ('John', 8, 3.78)
 STeVe> 'John bought 08 apples for 3.78'
 STeVe> alongside this::
 >>>> '{0:-10} bought {1:02i} apples for {2:3.2f}'.format('John', 8, 3.78)
 STeVe> 'John bought 08 apples for 3.78'
 STeVe> They're so similar I don't see why you think the latter is no
 STeVe> longer "easy and powerful".
You mean other than:
 * the new is more verbose than the old
 * the curly braces and [012]: prefixes are just syntactic sugar when
 converting old to new
 * in situations where the format string isn't a literal that mechanical
 translation from old to new won't be possible
 * lots of people are familiar with the old format, few with the new
?
I suppose nothing.
Skip


More information about the Python-3000 mailing list

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