I've always wondered why there isn't a bin() built-in in Python. Built-in functions already exist for converting ints to hexadecimal and octal strings and vice versa i.e.
s = hex() and int(s, 16) s = oct() and int(s, 8) but no bin() function for binary strings s = ??? and int(s, 2)? Working with hardware I occasionally need to display an integer in binary format, or manipulate the bits of integer. A simple example would be reversing the order of the bits. Converting an int to binary string, reversing the string, then converting back to an int is a simple way to do this. Right now I use the recipe in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/219300 and am happy to continue to do so, but it has always struck me as odd that there isn't a bin() built-in. Mike PS. I'll let someone else argue the case for the tri(), quad(), penta()... built-in functions. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com