Re: First script. Need some help

2010-05-27 Thread ledpepper
Thanks Everyone. I followed your instructions and my script is successfully copying the result to the clipboard. Now for the fun. To work out the rest of the script :) I use the IDLE IDE and not codepad.org. I just thought that was the standard for pasting scripts here in this group. Thanks all.

Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-27 Thread Sebastian Bassi
On Fri, May 28, 2010 at 12:37 AM, John Bokma wrote: > I feel more than uncomfortable with example code that uses: user="root" What's wrong with this? It is just an example of connection string. The reader will use his/her user/pass/dbname according to their own settings. > (e.g. p291). I never g

Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-27 Thread John Bokma
Sebastian Bassi writes: > Hello, I want to announce that the publisher of "Python for > Bioinformatis" (CRC Press) allowed me to publish a chapter from my > book. > I decided to publish the chapter about "Python and databases". I think > it may be useful for somebody. > The official announcement

Free chapter about Python and databases (MySQL and SQLite)

2010-05-27 Thread Sebastian Bassi
Hello, I want to announce that the publisher of "Python for Bioinformatis" (CRC Press) allowed me to publish a chapter from my book. I decided to publish the chapter about "Python and databases". I think it may be useful for somebody. The official announcement and download link is here: http://py4b

Re: pythonMagick question

2010-05-27 Thread Chris Rebert
On Thu, May 27, 2010 at 7:00 PM, wrote: > Hello, > > I'm wanting to try out pythonMagick, but am pretty lost with this whole thing. > What I'm wanting to do is view EPS and PDF files with Python and be able to > zoom into the images to see smaller detail. > > I downloaded PythonMagick-0.9.1.tar a

Re: ElementTree write creates large one line XML file ....

2010-05-27 Thread Sebastian Bassi
On Thu, May 27, 2010 at 9:13 PM, Robert Kern wrote: > ElementTree writes exactly what you tell it to. In XML, whitespace is > significant. If you want newlines and/or indentation to make it > pretty-looking, then you need to add those to your elements. This is not always true. Let me quote an XML

pythonMagick question

2010-05-27 Thread jyoung79
Hello, I'm wanting to try out pythonMagick, but am pretty lost with this whole thing. What I'm wanting to do is view EPS and PDF files with Python and be able to zoom into the images to see smaller detail. I downloaded PythonMagick-0.9.1.tar and have been looking through that folder. The REA

Tkinter error

2010-05-27 Thread ipatrol6010
I run a program (important parts at http://paste.pocoo.org/show/219148/) and all I get is this error: warning: callback failed in WindowList : invalid command name ".45328424.windows" Why? P.S.: Please CC all replies to me, I don't watch the list -- http://mail.python.org/mailman/list

Re: MySQLDB - server has gone on blob insertion...

2010-05-27 Thread John Nagle
Dennis Lee Bieber wrote: On Wed, 26 May 2010 11:30:41 +0200, Durumdara declaimed the following in gmane.comp.python.general: cursor.execute('delete from blobs;') Since that statement will delete EVERY record from the table "blobs", I believe it is common practice to replace it with

Re: ElementTree write creates large one line XML file ....

2010-05-27 Thread Robert Kern
On 5/27/10 7:52 PM, robert somerville wrote: Hi I am using Ubuntu 9.10 and Python 2.6.4 .. when I create an ElementTree object and the write it out using: xml.etree.ElementTree.write() , I get one single long single line files, instead of something that looks reasonable , what gives ??? (and

ElementTree write creates large one line XML file ....

2010-05-27 Thread robert somerville
Hi I am using Ubuntu 9.10 and Python 2.6.4 .. when I create an ElementTree object and the write it out using: xml.etree.ElementTree.write() , I get one single long single line files, instead of something that looks reasonable , what gives ??? (and is it important ??) eg: I get : OneTwo instea

Re: Some More MySQL

2010-05-27 Thread MRAB
Victor Subervi wrote: On Thu, May 27, 2010 at 2:54 PM, MRAB > wrote: Victor Subervi wrote: Hi; But what about this? sql = "select pic%d from %s where ID='%%s';" % (pic, store) cursor.execute(sql % id) If I try an

Re: Yet Another MySQL Problem

2010-05-27 Thread Tim Chase
On 05/27/2010 03:32 PM, Victor Subervi wrote: On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: That should be: ', '.join(['%s'] * len(values))) Or as I've done in the past: ', '.join('%s' for _ in values) Huh? Can you describe that underscore to me? Fascinating! The underscor

re ElemenTree producing and reading examples needed :

2010-05-27 Thread robert somerville
does anybody have some working code that they can point me to so i could see ElemenTtree in action (especially writing XML files) ??? Thanks Robert Somerville -- http://mail.python.org/mailman/listinfo/python-list

PyQt4 QThread - passing arguments to thread methods

2010-05-27 Thread nganon tj
Hi, I am trying to figure out how to implement a QThread class that will handle GUI event while keeping the GUI responsive. I want to call thread's methods by their names and start() the thread from inside that method. My problem is with passing methods their arguments since start() wont take any

Re: Question on Python Function

2010-05-27 Thread joy99
On May 25, 12:18 pm, Peter Otten <__pete...@web.de> wrote: > Kushal Kumaran wrote: > > On Tue, May 25, 2010 at 3:38 AM,joy99 wrote: > >> > > >> Dear Vlastimir, > > >> As pointed out by Alister, I can print the values of function1 and > >> function2 with the help of another function3, but my target

Tryton 1.6 series is out

2010-05-27 Thread ced
Tryton is a three-tiers high-level general purpose application platform under the license GPL-3 written in Python and using PostgreSQL as main database engine. It is the core base of a complete business solution providing modularity, scalability and security. This new release comes with the suppor

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote: > On 05/27/2010 11:56 AM, MRAB wrote: > >> Kushal Kumaran wrote: >> >>>', '.join('%s' * len(values))) >>> >> >> That should be: >> >> ', '.join(['%s'] * len(values))) >> > > Or as I've done in the past: > > ', '.join('%s' for _ in

Re: dbf files and indexes

2010-05-27 Thread Christian Heimes
Finally, are these SQL databases? The best way of getting information is with SQL. SELECT * FROM NumberOfPets WHERE name IN (SELECT name FROM CatLovers) OR name IN (SELECT name FROM DogLovers) ORDER BY name; A good way is to use SQL with JOINs instead of horrible nested selects. Although S

Re: dbf files and indexes

2010-05-27 Thread Ethan Furman
D'Arcy J.M. Cain wrote: On Thu, 27 May 2010 12:45:58 -0700 Ethan Furman wrote: Let's say I have two tables: CatLoversDogLovers --- --- | name | age | | name | age | |-| |-| [...] NumberOf

Re: Yet Another MySQL Problem

2010-05-27 Thread Tim Chase
On 05/27/2010 11:56 AM, MRAB wrote: Kushal Kumaran wrote: ', '.join('%s' * len(values))) That should be: ', '.join(['%s'] * len(values))) Or as I've done in the past: ', '.join('%s' for _ in values) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: dbf files and indexes

2010-05-27 Thread Ethan Furman
Ethan Furman wrote: Let's say I have two tables: Okay, let's say I have three tables instead. ;p -- http://mail.python.org/mailman/listinfo/python-list

Re: First script. Need some help

2010-05-27 Thread Dave Angel
ledpepper wrote: #Enter in firstname.lastname (bob.smith) #Count the amount of letters(x) and vowels(y) #Then work out if bob is > but not equal to 6 letters #If firstname is less than 6 print firstnamesurnamexy #If firstname is equal to or greater than 6 print firstnamexy #Copy result to clipboa

Re: dbf files and indexes

2010-05-27 Thread D'Arcy J.M. Cain
On Thu, 27 May 2010 12:45:58 -0700 Ethan Furman wrote: > Let's say I have two tables: > > CatLoversDogLovers > --- --- > | name | age | | name | age | > |-| |-| [...] > > NumberOfPets > -

On the installation of external Python modules

2010-05-27 Thread Wim R. Cardoen
Hello, In the past I installed different versions of python (using gcc) e.g. 2.5.4, 2.6.4 at the following places: /wim/pkg/python/2.5.4 /wim/pkg/python/2.6.4 I installed the numpy, scipy, matplotlib, dadi modules using the command: /wim/pkg/python/2.5.4/bin/python setup.py install --prefix=/wim

Re: First script. Need some help

2010-05-27 Thread Mark Lawrence
On 27/05/2010 19:41, ledpepper wrote: #Enter in firstname.lastname (bob.smith) #Count the amount of letters(x) and vowels(y) #Then work out if bob is> but not equal to 6 letters #If firstname is less than 6 print firstnamesurnamexy #If firstname is equal to or greater than 6 print firstnamexy #C

Re: First script. Need some help

2010-05-27 Thread MRAB
ledpepper wrote: #Enter in firstname.lastname (bob.smith) #Count the amount of letters(x) and vowels(y) #Then work out if bob is > but not equal to 6 letters #If firstname is less than 6 print firstnamesurnamexy #If firstname is equal to or greater than 6 print firstnamexy #Copy result to clipboa

dbf files and indexes

2010-05-27 Thread Ethan Furman
Let's say I have two tables: CatLoversDogLovers --- --- | name | age | | name | age | |-| |-| | Allen | 42 | | Alexis| 7 | | Jerod | 29 | | Michael | 21 | | Samuel

Re: Some More MySQL

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 2:54 PM, MRAB wrote: > Victor Subervi wrote: > >> Hi; >> But what about this? >> >> sql = "select pic%d from %s where ID='%%s';" % (pic, store) >> cursor.execute(sql % id) >> >> If I try and rewrite the last line like this: >> >> cursor.execute(sql, id) >> >> it doesn't

Re: Minor annoyances with properties

2010-05-27 Thread Francesco Bochicchio
On 27 Mag, 14:37, eb303 wrote: > Hello all, > > I've been using Python properties quite a lot lately and I've found a > few things that are a bit annoying about them in some cases. I > wondered if I missed something or if anybody else has this kind of > problems too, and if there are better soluti

Re: Some More MySQL

2010-05-27 Thread MRAB
Victor Subervi wrote: Hi; But what about this? sql = "select pic%d from %s where ID='%%s';" % (pic, store) cursor.execute(sql % id) If I try and rewrite the last line like this: cursor.execute(sql, id) it doesn't work. What do? How about this one: cursor.execute("insert into c

First script. Need some help

2010-05-27 Thread ledpepper
#Enter in firstname.lastname (bob.smith) #Count the amount of letters(x) and vowels(y) #Then work out if bob is > but not equal to 6 letters #If firstname is less than 6 print firstnamesurnamexy #If firstname is equal to or greater than 6 print firstnamexy #Copy result to clipboard http://codepad.

Some More MySQL

2010-05-27 Thread Victor Subervi
Hi; But what about this? sql = "select pic%d from %s where ID='%%s';" % (pic, store) cursor.execute(sql % id) If I try and rewrite the last line like this: cursor.execute(sql, id) it doesn't work. What do? How about this one: cursor.execute("insert into categories (Store, Catego

Re: matplotlib: show xticks only for discrete times

2010-05-27 Thread Mark Lawrence
On 27/05/2010 17:27, speedy66 wrote: I am plotting data that depends on time and height using pcolor. The data is collected every 30 minutes, so there will be data at 1PM and again at 1:30PM for instance. My question deals with how to get xticks to show up only for time values that actually ex

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 12:56 PM, MRAB wrote: > Kushal Kumaran wrote: > [snip] > > Since I'm in a good mood today, here's a little present: >> >> def insert(cursor, table, columns, values): >>"""Insert a row into a table. columns must be a list of column >>names. values must be a list

Re: A Quick MySQL Question

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 1:37 PM, Dennis Lee Bieber wrote: > On Wed, 26 May 2010 08:29:21 -0400, Victor Subervi > declaimed the following in > gmane.comp.python.general: > > > valueList = ("%value1", "%value2", "%value3") > >If I'd coded it correctly, there should have been a % on both sid

Re: Minor annoyances with properties

2010-05-27 Thread John Posner
On 5/27/2010 9:14 AM, Neil Cerutti wrote: On 2010-05-27, eb303 wrote: I've been using Python properties quite a lot lately and I've found a few things that are a bit annoying about them in some cases. I wondered if I missed something or if anybody else has this kind of problems too, and if ther

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 17:56 +0100, MRAB wrote: > Kushal Kumaran wrote: > [snip] > > Since I'm in a good mood today, here's a little present: > > > > def insert(cursor, table, columns, values): > > """Insert a row into a table. columns must be a list of column > > names. values must be a

Re: Yet Another MySQL Problem

2010-05-27 Thread MRAB
Kushal Kumaran wrote: [snip] Since I'm in a good mood today, here's a little present: def insert(cursor, table, columns, values): """Insert a row into a table. columns must be a list of column names. values must be a list of values for the new row. The columns and values must corr

Re: if, continuation and indentation

2010-05-27 Thread HH
On May 27, 11:37 am, Alain Ketterlin wrote: > HH writes: > >     if (width == 0 and > >         height == 0 and > >         color == 'red' and > >         emphasis == 'strong' or > >         highlight > 100): > >         raise ValueError("sorry, you lose") > > I prefer to see the "and" at the beg

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 12:11 PM, Kushal Kumaran wrote: > Since I'm in a good mood today, here's a little present: > > def insert(cursor, table, columns, values): >"""Insert a row into a table. columns must be a list of column >names. values must be a list of values for the new row. The

matplotlib: show xticks only for discrete times

2010-05-27 Thread speedy66
I am plotting data that depends on time and height using pcolor. The data is collected every 30 minutes, so there will be data at 1PM and again at 1:30PM for instance. My question deals with how to get xticks to show up only for time values that actually exist in the dataset. As an example, t

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 20:47 +0530, Kushal Kumaran wrote: > On Thu, 2010-05-27 at 10:30 -0400, Victor Subervi wrote: > > On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran > > wrote: > > > > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > > Hi; > > > I ha

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
MRAB wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit co

Re: multiprocessing and accessing server's stdout

2010-05-27 Thread Tim Arnold
On May 26, 4:52 pm, Adam Tauno Williams wrote: > On Wed, 2010-05-26 at 11:47 -0700, Tim Arnold wrote: > > Hi, > > I'm using multiprocessing's BaseManager to create a server on one > > machine and a client on another. The client fires a request and the > > server does some work, the result of which

Re: if, continuation and indentation

2010-05-27 Thread Alain Ketterlin
HH writes: > if (width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100): > raise ValueError("sorry, you lose") I prefer to see the "and" at the beginning of continuation lines, and usually group related items

Re: if, continuation and indentation

2010-05-27 Thread Harald Luessen
On Thu, 27 May 2010 HH wrote: >I have a question about best practices when it comes to line wrapping/ >continuation and indentation, specifically in the case of an if >statement. > >if (width == 0 and >height == 0 and >color == 'red' and >emphasis == 'strong' or >

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 10:30 -0400, Victor Subervi wrote: > On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran > wrote: > > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > Hi; > > I have this code: > > > > sql = "insert into %s (%s) va

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 10:17 AM, Kushal Kumaran wrote: > On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > > Hi; > > I have this code: > > > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > > string.join(cols[1:], ', ')) > > #cursor.execute(sql, string.join(v

Re: if, continuation and indentation

2010-05-27 Thread MRAB
HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, r

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 09:34 -0400, Victor Subervi wrote: > On Thu, May 27, 2010 at 8:34 AM, Victor Subervi > wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % > (personalDataTable, string.join(cols[1:], ', ')) >

Re: Yet Another MySQL Problem

2010-05-27 Thread Kushal Kumaran
On Thu, 2010-05-27 at 08:34 -0400, Victor Subervi wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > string.join(cols[1:], ', ')) > #cursor.execute(sql, string.join(vals[1:], "', '")) > cursor.execute('insert into %s (%s) values ("%

Re: if, continuation and indentation

2010-05-27 Thread Tim Chase
On 05/27/2010 07:22 AM, HH wrote: When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, rather than ending each line with an escape character. Thus, using the example from the style guide (http://www.python.org/

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 23:26, Xavier Ho wrote: > Oh, one minor optimisation. You can put the last condition first > I take that back. You really can't, without using more parans or ifs. Apologies. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
On Thu, May 27, 2010 at 8:34 AM, Victor Subervi wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, > string.join(cols[1:], ', ')) > #cursor.execute(sql, string.join(vals[1:], "', '")) > cursor.execute('insert into %s (%s) values ("%s"

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution >> >> if ( >> width == 0 and >> height == 0 and >> color == 'red' and >> emphasis == 'strong' or >> highlight > 100 >> ): >> raise ValueError("sorry, you lose

Re: Minor annoyances with properties

2010-05-27 Thread Christian Heimes
Do I miss something? Is this the way to do it, or is there a better one? A better way was introduced in Python 2.6. See http://docs.python.org/library/functions.html?highlight=property#property I have a Python only version around if you are still using Python 2.5. Christian -- http://mail.p

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution > > if ( > width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100 > ): > raise ValueError("sorry, you lose") > > But

Re: Minor annoyances with properties

2010-05-27 Thread Neil Cerutti
On 2010-05-27, eb303 wrote: > I've been using Python properties quite a lot lately and I've > found a few things that are a bit annoying about them in some > cases. I wondered if I missed something or if anybody else has > this kind of problems too, and if there are better solutions > than the one

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, r

Re: if, continuation and indentation

2010-05-27 Thread Martin P. Hellwig
On 05/27/10 13:22, HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the impli

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:22, HH wrote: >if (width == 0 and >height == 0 and >color == 'red' and >emphasis == 'strong' or >highlight > 100): >raise ValueError("sorry, you lose") > I've gotta say - I've bumped into this problem before, and I'm sure many other h

Minor annoyances with properties

2010-05-27 Thread eb303
Hello all, I've been using Python properties quite a lot lately and I've found a few things that are a bit annoying about them in some cases. I wondered if I missed something or if anybody else has this kind of problems too, and if there are better solutions than the ones I'm using ATM. The first

Yet Another MySQL Problem

2010-05-27 Thread Victor Subervi
Hi; I have this code: sql = "insert into %s (%s) values ('%%s');" % (personalDataTable, string.join(cols[1:], ', ')) #cursor.execute(sql, string.join(vals[1:], "', '")) cursor.execute('insert into %s (%s) values ("%s");' % (personalDataTable, string.join(cols[1:], ', '), string.join(va

if, continuation and indentation

2010-05-27 Thread HH
I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, rather than e

Re: confusing error with nntplib

2010-05-27 Thread Peter Otten
Eduardo Alvarez wrote: > When trying to use nntplib to connect to the news server nntp.aioe.org, > a bizarre sequence of events occurs: > > 1) I import the module, and create an instance, as follows: > > s = nntplib.NNTP('nntp.aioe.org') > > I get no errors, which leads me to believe all went w

Re: confusing error with nntplib

2010-05-27 Thread Martin P. Hellwig
On 05/27/10 02:01, Eduardo Alvarez wrote: When trying to use nntplib to connect to the news server nntp.aioe.org, a bizarre sequence of events occurs: 1) I import the module, and create an instance, as follows: s = nntplib.NNTP('nntp.aioe.org') I get no errors, which leads me to believe all we

Re: type error raise

2010-05-27 Thread Chris Rebert
On Thu, May 27, 2010 at 4:16 AM, timo verbeek wrote: > what is the problem with this code? > > _base={"repeat":False,"string":"Progres has failed","works":True} > print _base > class dictreturn(_base):pass You can't subclass a dictionary object, you can only subclass other classes. What on earth

type error raise

2010-05-27 Thread timo verbeek
what is the problem with this code? _base={"repeat":False,"string":"Progres has failed","works":True} print _base class dictreturn(_base):pass this error Traceback (most recent call last): File "", line 244, in run_nodebug File "C:\Documents and Settings\Owner\Desktop\Python\assistent new \us

Re: confusing error with nntplib

2010-05-27 Thread Alf P. Steinbach
* Eduardo Alvarez, on 27.05.2010 03:01: When trying to use nntplib to connect to the news server nntp.aioe.org, a bizarre sequence of events occurs: 1) I import the module, and create an instance, as follows: s = nntplib.NNTP('nntp.aioe.org') I get no errors, which leads me to believe all went

Re: Another Little MySQL Problem

2010-05-27 Thread Tim Golden
On 26/05/2010 23:24, Christian Heimes wrote: Actually, no. The names of tables are not quoted in SQL. One writes SELECT ID FROM mytable; not SELECT ID FROM "mytable"; nit picking mode: Some RDBMS support case sensitive table names. You have to quote the table name if you using the feature