Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
> The parenthesization you had earlier forced Python into printing out > your template before it had an opportunity to plug arg into it. You > need to do the interpolation first. Gaaah. Brain freeze. I was pointing at the wrong code. *grin* I meant to look at the other statement that you h

Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
On Sat, 15 Apr 2006, Tiago Saboga wrote: > Can I use string formatting in my own functions, or is it stuck with builtins? > It doesn't make much sense for me, but I don't understand the following > error: > > In [1]: var = 456 > > In [2]: def printd(arg): > ...: print('>>> %s') % arg > .

[Tutor] In[nnn], Out[nnn] (was: dictionary datatype

2006-04-15 Thread Terry Carroll
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? ___ Tutor maillist -

Re: [Tutor] Python video?

2006-04-15 Thread Richard Querin
On 4/13/06, Steve Nelson <[EMAIL PROTECTED]> wrote: On a similar line, I've recently discovered "podcasts".  I spend a lotof time driving, and have been listening through the "Security Now"broadcasts, and the last few days some stuff on Evolutionary Theory. Does anyone know of some good sources for

Re: [Tutor] School Boy Error

2006-04-15 Thread David Rock
* John CORRY <[EMAIL PROTECTED]> [2006-04-15 23:48]: > Thanks Brian for the help on the last one. I couldn't see the wood for > the trees. I have a tougher one for you. > > I am reading in a CSV file. Each line represents a line that I want to > upload into my database. I am trying to upload

Re: [Tutor] School Boy Error

2006-04-15 Thread Liam Clarke
Wait, I have put you wrong there. Can you please copy and paste here the output of print liney[-1] Thanks, Liam On 4/16/06, Liam Clarke <[EMAIL PROTECTED]> wrote: > Hi John, > > Listy will be a list of lists, and the DBAPI specifies tuples. So > either change this - > > listy.append(line) > > t

Re: [Tutor] School Boy Error

2006-04-15 Thread Liam Clarke
Hi John, Listy will be a list of lists, and the DBAPI specifies tuples. So either change this - listy.append(line) to listy.append(tuple(line)) or stick a list comprehension at the end if you need to mung anything in listy before passing it in: listy = [ tuple(item) for item in listy] Regard

Re: [Tutor] School Boy Error

2006-04-15 Thread Brian Gustin
would be helpful to paste the entire error information that python gives .. including the lines before and after. When pytho sets an error , it will tell you *exactly* where the error is at (or it should) I do all my development work on Linux, havent worked with ODBC databases, but the reference

[Tutor] string formatting (%s)

2006-04-15 Thread Tiago Saboga
Can I use string formatting in my own functions, or is it stuck with builtins? It doesn't make much sense for me, but I don't understand the following error: In [1]: var = 456 In [2]: def printd(arg): ...: print('>>> %s') % arg ...: In [3]: printd(var) >>> 456 In [4]: printd('Variab

Re: [Tutor] Is this correct?

2006-04-15 Thread Hoffmann
--- Alan Gauld <[EMAIL PROTECTED]> wrote: > Hi, > > > The goal is to write a function printTime that > takes a > > Time object as an argument and prints it in the > form > > hours:minutes:seconds. > > > > So, I wrote the script below: > > > > class Time: > > pass > > > > hour = int( raw_input(

Re: [Tutor] Is this correct?

2006-04-15 Thread Alan Gauld
Hi, > The goal is to write a function printTime that takes a > Time object as an argument and prints it in the form > hours:minutes:seconds. > > So, I wrote the script below: > > class Time: > pass > > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) >

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

2006-04-15 Thread Alan Gauld
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 stuff but I prefer to see wha

[Tutor] School Boy Error

2006-04-15 Thread John CORRY
Thanks Brian for the help on the last one.  I couldn’t see the wood for the trees.  I have a tougher one for you.   I am reading in a CSV file.  Each line represents a line that I want to upload into my database.  I am trying to upload the first line in the file to get myself started.  Th

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

2006-04-15 Thread Danny Yoo
> I am having problems amending records in my database. Hi John, The root of this problem is a matter of choosing variable names that are way too terse. In particular, note that you're using the variable 'c' as: c = 'PF1' but at the same time, you're also using: c = db.cursor()

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

2006-04-15 Thread John CORRY
Hi,   I am having problems amending records in my database.   If I use the following code my database is updated fine.   c = '"PF1"' b = 91.4 a = 85.00 import mx.ODBC import mx.ODBC.Windows db = mx.ODBC.Windows.DriverConnect('DSN=vfp') c = db.cursor() c.execute('UPDATE cost_gri

Re: [Tutor] (no subject)

2006-04-15 Thread Danny Yoo
> STOP SENDING ME MESSAGES I NEVER SIGNED UP TO YOUR MAILING LIST Followup --- unsubscribed. In the future --- and just so that others know --- if anyone has any administrative messages or "unsubscribe me" messages, send them to the administrators at: The administrative email address is:

[Tutor] (no subject)

2006-04-15 Thread x-ray ubeenstung
STOP SENDING ME MESSAGES I NEVER SIGNED UP TO YOUR MAILING LIST ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Is this correct?

2006-04-15 Thread Hoffmann
Hello: This question is regarding the first exercise of the book "How to think Like a Computer Scientist: Learning with Python", by Downey, Elkner, and Meyers, Chapter 13, page 137. The goal is to write a function printTime that takes a Time object as an argument and prints it in the form hours:m

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread Bob Gailer
John Corry wrote: > Liam, > > Thanks for the quick response. I have changed the code so that dsn is now > DSN. However I get the same error. I agree with Alan.the dsn should point to a data source rather than a file. To be more precise Start -> Settings -> Control Panel -> Administrative Tools

[Tutor] Good Hustle Hit the Showers!

2006-04-15 Thread John Corry
Hi, Good advice. I configured the ODBC data sources as advised and I am now able to query my database files. Thanks, John. -Original Message- From: Lloyd Kvam [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 16:04 To: [EMAIL PROTECTED] Cc: Kent Johnson; Tutor Python Subject: Re: [Tutor] o

Re: [Tutor] odbc

2006-04-15 Thread John Corry
Kent, I am not sure what you mean. I am feeling about in the dark on this subject. Do you have an example? Among my visual foxpro database files I have a file called tng.dbc. When I acces the database files through excel, I select the tng.dbc before I can see the fields in the databases. Is t

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread Alan Gauld
> I have downloaded the mxodbc product. I am using windows xp, python 2.4 > mx.ODBC.Windows.DriverConnect('dsn=c:/test/m2m/data/cost_grid.dbf') > OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data > source name not found and no default driver specified', 6044) > What am I doin

Re: [Tutor] odbc

2006-04-15 Thread Kent Johnson
John CORRY wrote: > I have just run the test package within mxODBC. I get the following result. > OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data > source name not found and no default driver specified', 6044) > > It gives me the same error that I am experiencing when I run

[Tutor] odbc

2006-04-15 Thread John CORRY
Hi,   I have just run the test package within mxODBC.  I get the following result.   mx.ODBC Test Suite   Subpackage Name [Windows]:  

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John Corry
Liam, Thanks for the quick response. I have changed the code so that dsn is now DSN. However I get the same error. Any other thoughts? Regards, John. -Original Message- From: Liam Clarke [mailto:[EMAIL PROTECTED] Sent: 15 April 2006 15:02 To: [EMAIL PROTECTED] Cc: tutor@python.org Su

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread Liam Clarke
According to the eGenix docs: Please refer to the ODBC manuals of your ODBC manager and database for the exact syntax of the DSN_string. It typically has these entries: 'DSN=datasource_name;UID=userid;PWD=password;' (case is important !). So, you've got DSN lowercase... On 4/16/06, John CORRY <

Re: [Tutor] PHP Functions in Python

2006-04-15 Thread Liam Clarke
Um. I suppose you could, but what are you trying to do? I'm fairly certain Python has similar functionality to PHP, and is a lot more straightforward than interfacing with a forked process. (Assuming you're using the PHP CLI and not talking PHP in Apache, etc.) On 4/15/06, Prabhakar K <[EMAIL PROT

[Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John CORRY
Hi,   I have downloaded the mxodbc product.  I am using windows xp, python 2.4 and I am trying to log onto a visual foxpro database file.  I have downloaded the visual foxpro driver.  I use the following code:   import mx.ODBC import mx.ODBC.Windows db = mx.ODBC.Windows.DriverConnect(

[Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread John CORRY
Hi,   I have downloaded the mxodbc product.  I am using windows xp, python 2.4 and I am trying to log onto a visual foxpro database file.  I have downloaded the visual foxpro driver.  I use the following code:   import mx.ODBC import mx.ODBC.Windows db = mx.ODBC.Windows.DriverConnect(

[Tutor] PHP Functions in Python

2006-04-15 Thread Prabhakar K
Hi,   I want to call php function in Python... is there any way to call. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor