how to add new print %b format to python?

Rusty Shackleford rs at overlook.homelinux.net
Mon Apr 26 11:02:25 EDT 2004


I have a Summer in front of me without any school, and I'd like to add a
new format for python print strings that will show any number in a
binary representation.  For example:

>>> '%b' % 3
11
>>> '%b' % 5
101

You get the idea.  I've written functions that return strings, so that
part is done, but where do I go to tinker with the python interpreter to
add this new format?

Please don't argue with me about whether this is an advisable goal in
itself -- I'm using it as a method to learn about the internals of the
python language.


-- 
My public key:
gpg --recv-keys --keyserver www.mandrakesecure.net 0x8D10BFD5



More information about the Python-list mailing list