On Thu, Mar 29, 2018 at 1:54 AM, Dan Stromberg <drsali...@gmail.com> wrote: > On Wed, Mar 28, 2018 at 7:30 AM, Ganesh Pal <ganesh1...@gmail.com> wrote: >>> >>> Or maybe they're not giving the same result. I'm a little confused here. >>> >> >> >> My Bad and Apologies , I should be fined for pasting wrong question. >> >> Actually I wanted to know if its ok to use just empty {} with .format() >> or use {} with values i.e {0} {1} both will give the same results anyway > > 2.6 and 3.0 do not like {}, but do like {0}. > > 2.7 and 3.1+ are fine with either.
Fairly weak argument there :) More notably, though: {0} {1} gives you stability, but {} {} gives you simplicity. Use whichever one makes more sense. And if you're creating localizable messages (where the template goes into a separate file and the formatting happens a long way separate from it), you can take flexibility even further by using {spam} {ham} and keyword arguments - extremely helpful when you're reading through the message file. ChrisA -- https://mail.python.org/mailman/listinfo/python-list