RESEARCHUT
Minds With Innovations

RESEARCHUT - minds with innovations

05 Feb '06 - 164 W - + 3 - 6 iprint - Andrew "Tridge" Tridgell's iprint in Python

Following code does the same thing that Tridge's iprint.c does. :-)
#!/usr/bin/env python
import sys
"iprint - Andrew \"Tridge\" Tridgell's iprint in Python"
def toBinary(dec):
"""
This function does the coversion from integer to binary
"""
    bin = ''
    while dec:
        bin = (dec % 2 and '1' or '0') + bin
        dec = long(dec/2)
    return bin or '0'
 
x = 1
text = ''
while len(sys.argv) > 1 and x < len(sys.argv):
    text += sys.argv[x]
    x += 1
 
for x in text:
    print ord(x), "\t", hex(ord(x)), "\t", oct(ord(x)), "\t", toBinary(ord(x)), "\t", x
    print "\n"
  
Remember personal info?

Emoticons / Textile

Sorry for the trouble but to prevent spam I require you to answer this silly question.
 

  (Register your username / Log in)

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

Trackback link:

Please enable javascript to generate a trackback url