Very stupid question about a % symbol
Jason Swails
jason.swails at gmail.com
Thu Sep 16 12:24:00 EDT 2010
Ha, I had this same problem, but I was trying to do dynamic formatting:
("%%%s" % format) % number
where "format" is a python-ized fortran format string (i.e. "9.4E"). Looks
kinda weird and less elegant than the {0:{1}}-type .format() syntax, but at
least it preserves backwards compatibility to pythons older than 2.6.
Before I found out how to cancel the %, the statement looked like ("%"+"%s"
% format) % number. Not much of a change, but still a nice thing to know
since I play with %s a lot.
Thanks! (even though I'm not the original asker)
Jason
On Thu, Sep 16, 2010 at 12:09 PM, Grant Edwards <invalid at invalid.invalid>wrote:
> On 2010-09-16, J <dreadpiratejeff at gmail.com> wrote:
>
> > Reported memory amounts are within 10% tolerance
>
> >>> "Reported memory amounts are within %d%% tolerance" % 10
> 'Reported memory amounts are within 10% tolerance'
>
> --
> Grant Edwards grant.b.edwards Yow! It's the RINSE
> CYCLE!!
> at They've ALL IGNORED the
> gmail.com RINSE CYCLE!!
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Graduate Student
352-392-4032
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100916/b710f8f1/attachment-0001.html>
More information about the Python-list
mailing list