Re: [Tutor] a question about symbol
linda.s wrote: > On 5/28/06, Bob Gailer <[EMAIL PROTECTED]> wrote: >> linda.s wrote: >> When I test the following code, >> I got something like (use 80 as argument): >> 80?F=27?C >> Why '?' appear? >> >> # code >> print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) >> >> On my computer I get the desired result. I paste it here 80°F = 27°C and I >> see degree symbols. >> >> What operating system / terminal hardware are you using? >> -- >> Bob Gailer >> 510-978-4454 > > mac and terminal. \260 represesents the character with octal value 260, hex B0. In Latin-1 and Unicode this is a degree sign. My guess is that your terminal is set to display UTF-8 characters rather than latin-1; in UTF-8 B0 by itself is an error. It's also possible it is set to MacRoman but in that case I think you would see an infinity sign instead of a question mark. From the Python interpreter prompt, type import sys sys.stdout.encoding to see what encoding your terminal is set to. If it is UTF-8, change the \260 to \xc2\xb0 which is the correct sequence for a degree sign in UTF-8. If it is MacRoman, change the \260 to \xa1 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question about symbol
On 5/28/06, Bob Gailer <[EMAIL PROTECTED]> wrote: > > linda.s wrote: > When I test the following code, > I got something like (use 80 as argument): > 80?F=27?C > Why '?' appear? > > # code > import string, sys > > # If no arguments were given, print a helpful message > if len(sys.argv)==1: > print 'Usage: celsius temp1 temp2 ...' > sys.exit(0) > > # Loop over the arguments > for i in sys.argv[1:]: > try: > fahrenheit=float(string.atoi(i)) > except string.atoi_error: > print repr(i), "not a numeric value" > else: > celsius=(fahrenheit-32)*5.0/9.0 > print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) > > On my computer I get the desired result. I paste it here 80°F = 27°C and I > see degree symbols. > > What operating system / terminal hardware are you using? > -- > Bob Gailer > 510-978-4454 mac and terminal. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] a question about symbol
When I run this program using your code on Ubuntu Linux, I get: ~$ ./c2f.py 44 44\uF = 7\uC Please notice that the code you have posted has indentation block errors. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question about symbol
linda.s wrote: When I test the following code, I got something like (use 80 as argument): 80?F=27?C Why '?' appear? # code import string, sys # If no arguments were given, print a helpful message if len(sys.argv)==1: print 'Usage: celsius temp1 temp2 ...' sys.exit(0) # Loop over the arguments for i in sys.argv[1:]: try: fahrenheit=float(string.atoi(i)) except string.atoi_error: print repr(i), "not a numeric value" else: celsius=(fahrenheit-32)*5.0/9.0 print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) On my computer I get the desired result. I paste it here 80°F = 27°C and I see degree symbols. What operating system / terminal hardware are you using? -- Bob Gailer 510-978-4454 Broadband Phone Service for local and long distance $19.95/mo plus 1 mo Free ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question about symbol
>> Let's compare the output to what we think is producing it. The very >> last statement in the program looks like the thing we want to watch: >> >> print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) >> >> One thing that caught me off guard is the '\260' thing. Can you explain >> what that is for? > > It is a sample code i downloaded. I think it is the symbol put before F > or C ( should be a small circle)...\I do not know why it appeared "?" Hi Linda, Ok, let's restate the question then. The question really seems to be: "How do I print a 'degree' symbol on the screen?" Does that sound right to you? Unfortunately, this is not such a fun problem to solve. It really depends on our output device --- the terminal --- and the support that our output device gives us. Some terminal displays don't provide much graphical support at all. In this case, you're seeing a question mark because the terminal has no clue how to render the character we're trying to display. Other terminals accept and display Unicode or other extended character sets, but it sounds like yours may not. You may want to read "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)" because it gives more background information on this ugly mess: http://www.joelonsoftware.com/articles/Unicode.html If it isn't too much of a deal for you, just change '\260' to 'degrees'. *grin* Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question about symbol
On 5/28/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Sun, 28 May 2006, linda.s wrote: > > > When I test the following code, > > I got something like (use 80 as argument): > > 80?F=27?C > > Why '?' appear? > > > Hi Linda, > > Let's compare the output to what we think is producing it. The very last > statement in the program looks like the thing we want to watch: > > print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) > > One thing that caught me off guard is the '\260' thing. Can you explain > what that is for? It is a sample code i downloaded. I think it is the symbol put before F or C ( should be a small circle)...\I do not know why it appeared "?" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a question about symbol
On Sun, 28 May 2006, linda.s wrote: > When I test the following code, > I got something like (use 80 as argument): > 80?F=27?C > Why '?' appear? Hi Linda, Let's compare the output to what we think is producing it. The very last statement in the program looks like the thing we want to watch: print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) One thing that caught me off guard is the '\260' thing. Can you explain what that is for? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] a question about symbol
When I test the following code, I got something like (use 80 as argument): 80?F=27?C Why '?' appear? # code import string, sys # If no arguments were given, print a helpful message if len(sys.argv)==1: print 'Usage: celsius temp1 temp2 ...' sys.exit(0) # Loop over the arguments for i in sys.argv[1:]: try: fahrenheit=float(string.atoi(i)) except string.atoi_error: print repr(i), "not a numeric value" else: celsius=(fahrenheit-32)*5.0/9.0 print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor