string conversion and formatters

John Hunter jdhunter at nitace.bsd.uchicago.edu
Sat Dec 8 13:26:11 EST 2001


>>>>> "Spiffy" == Spiffy  <clams17 at yahoo.com> writes:

    Spiffy> Doh!  Wow, you guys are the best...the BEST!! Thanks for
    Spiffy> your help. What a great community thang Python's got going
    Spiffy> here. Hopefully, I will be able to contibute in a
    Spiffy> meaningful way someday...  Here's my re-write and ...IT
    Spiffy> WORKS NOW!!  #Decimal/Hex Convertor

Since you're into learning python and converting numbers, why don't
you use a regular expression to detect whether the input string is
decimal, hex or octal, and then spit out the conversions to the other
two.

0xff  looks like hex
064   looks like octal (leading '0')
92    looks like decimal

Have fun,
John Hunter



More information about the Python-list mailing list