Re: [Tutor] Didn't take long to hit my next wall!

2006-04-16 Thread Brian Gustin
Interesting.. I'll have to dig out my unit test scripts that I wrote to test the situation to my satisfaction... The way I had it , I wrote the query exactly as was done in this case, but I wrote it directly in the cursor.execute() function as in: cursor.execute('''insert into tablea (id,name,nu

Re: [Tutor] Didn't take long to hit my next wall!

2006-04-16 Thread Kent Johnson
Brian Gustin wrote: > python in this form uses BIND variables.. > >>query = '''UPDATE cost_grid > >> SET cost_1 = %s <--- %s = the bind variable > placeholder/formatter > >> WHERE cost_grid_id = %s > >> AND finish_dro = %s % ( a,c,b) <--- the raw

Re: [Tutor] Didn't take long to hit my next wall!

2006-04-16 Thread Brian Gustin
python in this form uses BIND variables.. >>query = '''UPDATE cost_grid >> SET cost_1 = %s <--- %s = the bind variable placeholder/formatter >> WHERE cost_grid_id = %s >> AND finish_dro = %s % ( a,c,b) <--- the raw tuple That is, what is provi

Re: [Tutor] School Boy Error

2006-04-16 Thread Brian Gustin
I wonder if it could not be the extra comma (,) at the end of your sql ? thus: ..?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)<--- see trailing comma, and no matching ? could be a value count != column count mis-match make sure you have the correct number of values to each column :) On the oth

Re: [Tutor] In[nnn], Out[nnn]

2006-04-16 Thread Kent Johnson
Terry Carroll wrote: > On Wed, 12 Apr 2006, Victor Bouffier wrote: > >> In [285]: n = 0x2018 >> >> In [286]: n >> Out[286]: 8216 > > Victor -- > > I've seen this notation 00 e.g., In [286], Out[286] -- in a few people's > postings. What variety of Python does this? IPython http://ipython.scip

Re: [Tutor] Didn't take long to hit my next wall!

2006-04-16 Thread Kent Johnson
Alan Gauld wrote: > Hi John, > > I've no idea why its not working but this illustrates why I prefer to create > the sql string outside the execute - its a lot easier to debug when you can > print the string exactly as passed to execute. I know many others like to > leave execute to do the escaping

[Tutor] School Boy Error - Update

2006-04-16 Thread John CORRY
Hi,   I have taken on board the advice in relation to the cvs module and setting the list to a tuple.  I am now using the following code and getting a different error.  I think it is a small step forward?   import string, re path = "c:/test/import.csv" listy = [] import csv reader =

Re: [Tutor] Is this correct?

2006-04-16 Thread Kent Johnson
Hoffmann wrote: > So, I wrote the script below: > > class Time: > pass > > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) > sec = int( raw_input('Enter the sec: ') ) > > time = Time() > time.hours = hour > time.minutes = min > time.seconds

Re: [Tutor] Is this correct?

2006-04-16 Thread Kent Johnson
Hoffmann wrote: > class Time: > def __init__(self, hours = 0, minutes = 0, seconds = > 0): > self.hours = hours > self.minutes = minutes > self.seconds = seconds > > def printTime(self): # By convention, the first > parameter of a metho

[Tutor] School Boy Error

2006-04-16 Thread John CORRY
Bri,   Print stat gives   Insert into cost_grid values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,) Tracebac

Re: [Tutor] School Boy error

2006-04-16 Thread Brian Gustin
instead of c.execute(stat, listy[-1]) try sql_list = listy[-1] c.execute(stat, sql_list) Also what does print stat give you? maybe one of those two would tell us .. Bri! John CORRY wrote: > Hi, > > > > I couldn’t sleep last night with all the code running though my head. > Counting sheep d

[Tutor] School Boy error

2006-04-16 Thread John CORRY
Hi,   I couldn’t sleep last night with all the code running though my head.  Counting sheep didn’t work as I kept wanting to turn them into a loop!   listy[-1]   Outputs the following:-   ['432', 'TM BLIND', 'RO', 'PF1', 'Plain Finish Range One', '304.8', '', '45.7', '80', '90', '0'

Re: [Tutor] string formatting (%s)

2006-04-16 Thread Alan Gauld
> Can I use string formatting in my own functions, or is it stuck with > builtins? No, you can use it too. > It doesn't make much sense for me, but I don't understand the following > error: > In [2]: def printd(arg): > ...: print('>>> %s') % arg The format operator needs to be with the

Re: [Tutor] Is this correct?

2006-04-16 Thread Alan Gauld
>> Personally I prefer to put the initialisation >> into an __init__() method, > Thanks for your comments. Please, see below a new > version of that exercise. What do you think? > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) > sec = int( raw_input('