On Thu, Oct 30, 2008 at 11:03 PM, Peter Anderson < [EMAIL PROTECTED]> wrote:
> My problem is with the actual entry of the ASCII codes. My solution has a > "if" test to remove the leading "0" from an input of say "033". With this > test the output of the decode is correct in printing "!". Without the "if" > test the output is "\x1b" at best or a run-time error for other numbers. That is because the leading 0 marks the number as octal when eval() interprets it as a number. > My question is this: is there a better way to convert raw input of say > "033" to "33" than what I have used? Thanks in advance for any help. Dj's use of int() is the best way to do this. For future reference, the easy way to strip leading 0's from a string is with lstrip(): In [5]: '033'.lstrip('0') Out[5]: '33' Kent
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor