maping two-digit integers to a single ascii character, inverse of ord()?

Sean 'Shaleh' Perry shalehperry at attbi.com
Thu Aug 22 20:39:34 CEST 2002


On Thursday 22 August 2002 11:24 am, Jeff Kowalczyk wrote:
> > Is there an inverse function of ord()?
>
> chr(), doh! but it turns out that I'll probably have to write a dictionary
> encoding, since my limited range of integers (1 to 50) will cross at least
> some punctuation character boundaries, and I'd rather not work with those
> on the device, sticking with (0-9,A-z).
>
> Thanks if anyone still has a nice integer mapping tip that will work here.

if i < 26:
  chr(i + 64)
else:
  chr(i + 70) # (i - 26) + 96

that should map you into A-Xa-x land (sorry no z).




More information about the Python-list mailing list