Re: [Tutor] MS SQL Connection

2007-05-21 Thread Martin Walsh
Kent Johnson wrote: > Leon Keylin wrote: >> Thanks Mike, unfortunately that's the mod I had problems with before. >> The one that >> can't do truncate. I've written about it before here and it was easier >> to look for >> another solution. > > You could try adodbapi > http://adodbapi.sourceforge

[Tutor] creating a buffer object from a file ?

2007-05-21 Thread Iyer
How do I go about creating a buffer object from a file containing binary data ? I have a function that accepts only buffer objects for it's parameters and would like to pass on the contents of a file to that function. thanks, iyer - You snooze, you l

Re: [Tutor] Behaviour of dictionaries and others when deleting?

2007-05-21 Thread Kent Johnson
Bill Campbell wrote: > Is the behaviour defined if one is processing a dictionary using > iteritems, and delete items? > > for k, v in d.iteritems(): > if somecondition(k, v): del d[k] > > Would this process all the original members of the dictionary? This is not well-defined. You can use

Re: [Tutor] MS SQL Connection

2007-05-21 Thread Kent Johnson
Leon Keylin wrote: > Thanks Mike, unfortunately that's the mod I had problems with before. > The one that > can't do truncate. I've written about it before here and it was easier > to look for > another solution. You could try adodbapi http://adodbapi.sourceforge.net/ Kent > Is there any other

Re: [Tutor] MS SQL Connection

2007-05-21 Thread johnf
On Monday 21 May 2007 16:21, Leon Keylin wrote: > Thanks Mike, unfortunately that's the mod I had problems with before. The > one that > can't do truncate. I've written about it before here and it was easier to > look for > another solution. > > Is there any other way? Should I be looking for a dif

[Tutor] Behaviour of dictionaries and others when deleting?

2007-05-21 Thread Bill Campbell
Is the behaviour defined if one is processing a dictionary using iteritems, and delete items? for k, v in d.iteritems(): if somecondition(k, v): del d[k] Would this process all the original members of the dictionary? How about doing something similar with bsddb files? I've always been leary

Re: [Tutor] MS SQL Connection

2007-05-21 Thread Leon Keylin
Thanks Mike, unfortunately that's the mod I had problems with before. The one that can't do truncate. I've written about it before here and it was easier to look for another solution. Is there any other way? Should I be looking for a different language to do it in? -Original Message- F

Re: [Tutor] for k,v in d: ValueError: too many values to unpack

2007-05-21 Thread John Fouhy
On 22/05/07, John Washakie <[EMAIL PROTECTED]> wrote: > I have a Dictionary, that is made up of keys which are email > addresses, and values which are a list of firstname, lastnamet, > address, etc... > > If I run the following: > > last = {} [...] > for k,v in last: > print "Email: %s , ha

Re: [Tutor] MS SQL Connection

2007-05-21 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Leon Keylin > Sent: Monday, May 21, 2007 3:52 PM > To: tutor@python.org > Subject: [Tutor] MS SQL Connection > > Been trying to do a very small and simple select via Python. > First I tried a modul

[Tutor] MS SQL Connection

2007-05-21 Thread Leon Keylin
Been trying to do a very small and simple select via Python. First I tried a module that looked clean but it couldn't truncate tables. Then I started sifting through docs at python.org and couldn't find a simple way of communicating with a MS SQL via Python program. Do I have to use ODBC? Any e

[Tutor] for k,v in d: ValueError: too many values to unpack

2007-05-21 Thread John Washakie
I have a Dictionary, that is made up of keys which are email addresses, and values which are a list of firstname, lastnamet, address, etc... If I run the following: #! /bin/python import csv last = {} rdr = csv.DictReader(file("reg-data.csv")) for row in rdr: #print row last[row

Re: [Tutor] string replacement

2007-05-21 Thread Luke Paireepinart
Chandrashekar wrote: > Hi, > > I am trying to do something like this in python. Can you please help? > > handle= open('test.txt','a') > > handle.write(''' > > Testsomething$i > > something$i-test > > ''' > ) > > when i write into the file, i would like to have the output like this. > > Testsomethin

Re: [Tutor] string replacement

2007-05-21 Thread Tom Tucker
One way is... CODE #!/usr/bin/python handle = file("test.txt",'a') number = 1 for num in range(1,5): handle.write("TestingSome%s\n" % (number)) handle.write("something%s-test\n" % (number)) number += 1 handle.close() OUTPUT TestingSome1 something1-

Re: [Tutor] Continue Matching after First Match

2007-05-21 Thread Tom Tucker
Alan & Martin, Thanks for the feedback and suggestions. Kodos is a great tool. I use it regularly to debug my regex mistakes. It can also be a excellent learning tool to those unfamiliar with regular expressions. Thanks for the Python-LDAP link and ldif example code. On 5/20/07, Martin Wals

Re: [Tutor] string replacement

2007-05-21 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Well, there are a number of ways to achieve this, but the classical one would be: """abc%(i)s def%(i)s """ % dict(i=1) Andreas Chandrashekar wrote: > Hi, > > I am trying to do something like this in python. Can you please help? > > handle= open('t

[Tutor] string replacement

2007-05-21 Thread Chandrashekar
Hi, I am trying to do something like this in python. Can you please help? handle= open('test.txt','a') handle.write(''' Testsomething$i something$i-test ''' ) when i write into the file, i would like to have the output like this. Testsomething1 something1-test Testsomething2 something2-test