Re: [Tutor] ASCII Conversion

2012-01-31 Thread Joel Goldstick
On Tue, Jan 31, 2012 at 4:06 AM, Russel Winder wrote: > On Tue, 2012-01-31 at 07:33 +0200, Christian Witts wrote: >> [...]o with >> `type(y) == int`, and to get the ASCII value of a character you can use >> `ord` like `ord('a') == 97`. And how to avoid your ValueError with a bad >> conversion, do

Re: [Tutor] ASCII Conversion

2012-01-31 Thread Russel Winder
On Tue, 2012-01-31 at 07:33 +0200, Christian Witts wrote: > [...]o with > `type(y) == int`, and to get the ASCII value of a character you can use > `ord` like `ord('a') == 97`. And how to avoid your ValueError with a bad > conversion, do your type checking before hand. isinstance ( y , int )

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Peter Otten
Peter Otten wrote: > if isint and y < -1 or y > 1: Sorry, I forgot the parentheses. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Peter Otten
Michael Lewis wrote: > I am trying to do a simple test but am not sure how to get around ASCII > conversion of characters. I want to pass in y have the function test to > see if y is an integer and print out a value if that integer satisfies the > if statement. However, if I pass in a string, it's

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Blockheads Oi Oi
On 31/01/2012 05:33, Christian Witts wrote: On 2012/01/31 06:50 AM, Michael Lewis wrote: I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer sa

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Christian Witts
On 2012/01/31 06:50 AM, Michael Lewis wrote: I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer satisfies the if statement. However, if I pas

Re: [Tutor] ASCII Conversion

2012-01-30 Thread David Kidd
On Tue, Jan 31, 2012 at 15:50, Michael Lewis wrote: > ... However, if I pass in a string, it's converted to ASCII and will > still satisfy the if statement and print out value. How do I ensure that a > string is caught as a ValueError instead of being converted? It depends on what you want to do

[Tutor] ASCII Conversion

2012-01-30 Thread Michael Lewis
I am trying to do a simple test but am not sure how to get around ASCII conversion of characters. I want to pass in y have the function test to see if y is an integer and print out a value if that integer satisfies the if statement. However, if I pass in a string, it's converted to ASCII and will s