"Ganesh Pal" wrote in message news:CACT3xuUmOzR=5G9=zaf3fp2lytbgjv74vsyjfsvsifo77lf...@mail.gmail.com...

 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

The benefit of using empty {} is that you can easily add new 'fields' to the template without having to renumber all the existing ones.

The benefit of using numbers is when you want to re-use the same value in multiple elements of the template. Instead of declaring the value multiple times, declare it once, and assign its numerical position to all the elements in the template that use that value. They will all be populated with the same value.

Personally, I always use empty {} unless point 2 above applies.

Frank Millman


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to