Re: [Tutor] Enumeration and constant
Brendan Cheng wrote: I wander how to setup the enumeration type and constant in Python, which I couldn't find the topic in the help file. There is no built-in enumeration type. See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67107 for an example of an enumeration class. -- 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
[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
[Tutor] Enumeration and constant
Hi, I wander how to setup the enumeration type and constant in Python, which I couldn't find the topic in the help file. I'm using python 2.4.3 please give me an example of it as well Thanks, Brendan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Enumeration and Constant
Hi, I wander how to setup the enumeration type and constant in Python, which I couldn't find the topic in the help file. I'm using python 2.4.3 please give me an example of it as well Thanks, Brendan ___ 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
[Tutor] MySQLdb.converters.escape() type error
Hi, after upgrading to MySQL 5 and MySQLdb 1.2.1_p2, I have the following problem: self.db=MySQLdb.connect(host=host, user=user, passwd=passwd, db=db, cursorclass=MySQLdb.cursors.DictCursor) stringel = 'Some string' stringel = self.db.escape(stringel) File "./test.py", line 12, in ? stringel = self.db.escape(stringel) TypeError: no default type converter defined I checked the documentation for MySQLdb.converters and saw that the escape() function takes a dictionary as an obligatory second argument. This is odd, because I have always been using escape(string) without a problem. The changes in MySQLdb 1.2.1_p2 list: "Mapped a lot of new 4.1 and 5.0 error codes to Python exceptions" Could someone point me to the problem in the MySQL side? Thanks in advance! - Jan -- Any technology which is distinguishable from magic is insufficiently advanced. ___ 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