"Dan Bishop" <[EMAIL PROTECTED]> wrote: > On Mar 10, 11:50 am, Duncan Booth <[EMAIL PROTECTED]> > wrote: >> "Jack" <[EMAIL PROTECTED]> wrote: >> > This is a naive question: >> >> > "%u" % -3 >> >> > I expect it to print 3. But it still print -3. >> >> Internally it uses the C runtime to format the number, but if the >> number you ask it to print unsigned is negative it uses %d instead of >> %u. I have no idea if it is actually possibly to get a different >> output for %d versus %u. > > %u used to be different from %d, but it changed because of the int/ > long unification in Python 2.4. > Yes, I guessed that was it.
The implementation is identical when the value is negative but still different when the integer is non-negative which is why I questioned whether it was actually possible to get different output. If not perhaps both the implementation and the documentation should be simplified. -- http://mail.python.org/mailman/listinfo/python-list