difference between %s and %d

Grant Edwards invalid at invalid.invalid
Fri Oct 1 15:25:35 EDT 2010


On 2010-10-01, Ethan Furman <ethan at stoneleaf.us> wrote:

> If I'm printing the number 735, or any other positive or negative
> integer, is there any difference between %7s and %7d?

Let's ask Python:

  >>> [n for n in range(-99999999,99999999,123) if ("%7d" % n) != ("%7s" % n)]
  []

  >>> [n for n in range(-99999,99999) if ("%7d" % n) != ("%7s" % n)]
  []
  
Apparently not.

-- 
Grant Edwards               grant.b.edwards        Yow! What I want to find
                                  at               out is -- do parrots know
                              gmail.com            much about Astro-Turf?



More information about the Python-list mailing list