what does %u mean?

Y

yaru22

Hi. I just started learning python.

In the exercise in my book, it asks me to try print "%u" % (-5)

I'm wondering what this %u mean?

Thank you.

Regards,

Brian.
 
S

scruffy.mogwai

I'm not sure, but I think it has something to do with unicode.
print "%i" % 1 // Prints the integer 1 as a string.
print "%u" % (-5) // Prints -5 as a unicode string???
 
K

K.S.Sreeram

yaru22 said:
In the exercise in my book, it asks me to try print "%u" % (-5)
I'm wondering what this %u mean?

Looks like there is *no* difference between '%u' and '%d' in Python.

Python 2.4.3 source code:
from stringobject.c, formatint function....

if (x < 0 && type == 'u') {
type = 'd';
}


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEiO6brgn0plK5qqURApDpAKCu4v6Q9AC1VUIU2bX1beLuC1pMMgCfQbIM
duEz2HjDy5ZvnQi6Ii1VwUY=
=tk7r
-----END PGP SIGNATURE-----
 
S

scruffy.mogwai

Someone beat me to the reply -- and their explanation sounds a lot
better than mine!
i guess you learn something new everyday...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,588
Members
45,100
Latest member
MelodeeFaj
Top