Why does this (not) work?

Michael C. Neel neel at mediapulse.com
Tue Aug 19 17:43:27 EDT 2003


> try this:
> >>> "%s - %s - %s" % (("test",)*3)
> 
> why else would
> >>> 3 % 1 * 2
> print 0 instead of 1?
> 
> Jeff

Hmmm, can't say I like what this implies.  In one case % is shorthand
for a sprintf function, the other it's a mathematical expression at the
same level of precedence of * and /.  But the sprintf version is
"granted" the precedence of the mathematical version?  What's the logic
behind that? 

Oh well,
Mike





More information about the Python-list mailing list