Re: [Tutor] Postgresql+Python -tutorial?

2006-02-10 Thread Bill Campbell
On Sat, Feb 11, 2006, Joal Heagney wrote: >Alan G wrote: >>> I've been using MySQL up this day, but would like to convert >>> my program to use Postgresql. >> >> I'm curious. Why? >> Is there some advantage to Postgres over MySql? > >Yes and no. Postgresql offers more features and is IMO more fl

Re: [Tutor] small floating point number problem

2006-02-10 Thread Bengt Richter
On Wed, 08 Feb 2006 03:08:25 -0500, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Smith] >>I just ran into a curious behavior with small floating points, trying to >>find the limits of them on my machine (XP). Does anyone know why the '0.0' >>is showing up for one case below but not for the

Re: [Tutor] IDE - Editors - Python

2006-02-10 Thread Joal Heagney
Paul Kraus wrote: > Which editors does everyone use and why. Please keep the discussion to IDE's > rather then any editors. I am well versed on Emacs and VI so anything beyond > them would be appreciative. Why you like the editor and how it helps reduce > your development time would be productiv

Re: [Tutor] Postgresql+Python -tutorial?

2006-02-10 Thread Joal Heagney
Alan G wrote: >> I've been using MySQL up this day, but would like to convert >> my program to use Postgresql. > > I'm curious. Why? > Is there some advantage to Postgres over MySql? Yes and no. Postgresql offers more features and is IMO more flexible than most SQL servers out there. Example:

Re: [Tutor] nutshell review

2006-02-10 Thread Terry Carroll
On Fri, 10 Feb 2006, Carroll, Barry wrote: > Another book I have just found that may turn out useful is "Python > Programming Patterns" by Thomas W. Christopher, published by Prentice > Hall PTR. I got that from the library about a year ago. I found it interesting, but not too helpful. One pr

Re: [Tutor] nutshell review

2006-02-10 Thread Terry Carroll
It's the Python Essential Reference book, Third Edition due out February 24. I'm not aware of a new Nutshell coming out. On Fri, 10 Feb 2006 [EMAIL PROTECTED] wrote: > See I couldn't tell if he was talking about the Nutshell book or the Python > Essential Reference book...thanks > Carl > >

Re: [Tutor] Iterating over a string: index and value

2006-02-10 Thread Victor Bouffier
On Fri, 2006-02-10 at 12:42 -0800, Carroll, Barry wrote: > I seem to recall reading somewhere that it is possible to concurrently > generate the index and value of a string’s characters in a single for > statement. Is this true or did imagine it? > > > > Here is the scenario: > > > > Given

Re: [Tutor] cannonical matrix representation?

2006-02-10 Thread Smith
| 3. cannonical matrix representation? (Mike Cheponis) | | What's the best way to represent a matrix M with 4 dimensions, such | as M[x][y][z][t] where each element in the sparse matrix could be a | simple number, or could be an executable Python function snipped that | returns a value when that

Re: [Tutor] Splitting long string into same len parts

2006-02-10 Thread Victor Bouffier
On Thu, 2006-02-09 at 09:45 +, Alan Gauld wrote: > > Define easier :-) > Right! > You could just use string slicing and a stepsize of 3 in range: > > lst = [mystring[index : index+3] for index in range(0,len(mystring),3)] > Ever since I found them, list comprehensions are my favorites.

Re: [Tutor] Splitting long string into same len parts

2006-02-10 Thread Victor Bouffier
Aha!!! I believe this is what I was looking for in the first place (not that I will use it anyway, given the alternatives provided by others). I guess that coming from a Perl background, which as you know includes regexes as part of the core language, you tend to look to all solutions through this

Re: [Tutor] Splitting long string into same len parts

2006-02-10 Thread Victor Bouffier
WOW!! This is really great. Thanks Ken. This first one is definitely going to my personal scripts directory ;-) Victor On Thu, 2006-02-09 at 05:56 -0500, Kent Johnson wrote: > Victor Bouffier wrote: > > Hi to all, > > > > I'd like to split a long string into equally long strings (len(str) = >

Re: [Tutor] Trying a csv error

2006-02-10 Thread Tim Johnson
Hi Danny: Thanks! tim (who_should_have_read_the_docs) * Danny Yoo <[EMAIL PROTECTED]> [060210 13:56]: > > I'd like to do the following > > while(1): > > try: > > reader.next() ## csv object method > > except cvs._csv.Error: ## or something like this > > print "bad csv

Re: [Tutor] Iterating over a string: index and value

2006-02-10 Thread Alan Gauld
> generate the index and value of a string's characters in a single for > statement. Is this true or did imagine it? >>> for i,c in enumerate('fred'): print i,c ... 0 f 1 r 2 e 3 d Like that? Alan G. ___ Tutor maillist - Tutor@python.org http://ma

Re: [Tutor] cannonical matrix representation?

2006-02-10 Thread Alan Gauld
> p.s. This seems to me like it ought to be built into the base language > - multidimensional object arrays. The only languages I know that truly support anything like what you want are programmes like Mathematica and arguably MS Excel Basic... There is a pseudo mathematica somewhere in Pytho

Re: [Tutor] Trying a csv error

2006-02-10 Thread Danny Yoo
> I'd like to do the following > while(1): > try: > reader.next() ## csv object method > except cvs._csv.Error: ## or something like this > print "bad csv record, skipping " > continue > except StopIteration: > break > > The problem is that python do

Re: [Tutor] cannonical matrix representation?

2006-02-10 Thread Andre Roberge
On 2/10/06, Mike Cheponis <[EMAIL PROTECTED]> wrote: > What's the best way to represent a matrix M with 4 dimensions, such as > M[x][y][z][t] where each element in the sparse matrix could be a simple > number, or could be an executable Python function snipped that returns a > value when that cel

Re: [Tutor] Iterating over a string: index and value

2006-02-10 Thread Carroll, Barry
Adam, That is super! Just what I was looking for. Thanks! And whaddya know? There it is in the Python 2.3 Library reference, section 2.1! Regards,   Barry [EMAIL PROTECTED] 541-302-1107 "Never trust anything that can think for itself if you can't see where it keeps i

[Tutor] Trying a csv error

2006-02-10 Thread Tim Johnson
Hello: I'm using the csv module, and resources are imported as in import csv My exception trapping uses etype, value, tb = sys.exc_info() and I'm getting the following value = "newline inside string" type = "_csv.Error" I would like to proceed with the assumption for now that this error should no

[Tutor] Change files

2006-02-10 Thread David Holland
I wrote a little program that replaces all files called 'abcde' with the file in the directory from which you riun the program.  However it does not find them (there is another one). What have I done wrong :- #this program copies the file x to all other places in the directory. #however it does not

Re: [Tutor] Iterating over a string: index and value

2006-02-10 Thread Adam
Here's a list comprehension which does it:>>> print [(i, ord(v)) for i, v in enumerate("abcdefg")][(0, 97), (1, 98), (2, 99), (3, 100), (4, 101), (5, 102), (6, 103)]and a for loop: >>> for i, v in enumerate("abcdefg"):... tuplseq.append((i, ord(v)))...>>> tuplseq[(0, 97), (1, 98), (2, 99), (3,

Re: [Tutor] IDE - Editors - Python

2006-02-10 Thread Edgar Antonio Rodriguez Velazco
Try with Python Card.    ; )-- Edgar A. Rodriguez V. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Iterating over a string: index and value

2006-02-10 Thread Carroll, Barry
I seem to recall reading somewhere that it is possible to concurrently generate the index and value of a string’s characters in a single for statement.  Is this true or did imagine it?   Here is the scenario:   Given an ASCII string of arbitrary length and content, generate a sequence o

Re: [Tutor] cgi script: how to continue a process in the background and return from cgi script

2006-02-10 Thread Hugo González Monteverde
> So, could some give me a pointer to possible solutions ? Do I have to > make the last part of my program a seperate program and go through a > system call ? Hi, I have had this problem before. The timeout problem with Apache remains because STDOUT of both child and the parent are open. Apac

Re: [Tutor] cgi script: how to continue a process in the backgrou nd and return from cgi script

2006-02-10 Thread Beilin Zhang
I think you need to close the IO streams before forking the child process. Something like sys.stdout.flush() sys.stdout.close() sys.stdin.close() sys.stderr.close() os.close(0) os.close(1) os.close(2) This is probably not the best way, but it works for me. Beilin Zha

[Tutor] cannonical matrix representation?

2006-02-10 Thread Mike Cheponis
What's the best way to represent a matrix M with 4 dimensions, such as M[x][y][z][t] where each element in the sparse matrix could be a simple number, or could be an executable Python function snipped that returns a value when that cell is evaluated? The user of the program will type in Python

Re: [Tutor] nutshell review

2006-02-10 Thread Carroll, Barry
Greetings: I have been programming in Python for about a year. We use Python 2.3; we haven't migrated to 2.4 because the Real-time OS we use in our test systems doesn't yet support it. I have the four O'Reilly 'standards' as well ("Nutshell", "Learning", "Cookbook", and "Programming"). I use "N

Re: [Tutor] nutshell review

2006-02-10 Thread carl.badgley
Thanks for the info.../sigh well I shall be waiting with bells onCarlOn 2/10/06, Kent Johnson <[EMAIL PROTECTED] > wrote:nephish wrote:> yeah, one of the guys that posted earlier mentioned late feb as a > release of the new one. i think i am going to go ahead and get the> cookbook now, and then pic

[Tutor] cgi script: how to continue a process in the background and return from cgi script

2006-02-10 Thread Moritz Lennert
Hello, I need some pointers in the right direction for the following problem: I have a cgi script which reads in some form elements, uses them to compose an SQL query, sends that query to the postgresql backend, writes the results into a temporary file and sends a mail to the user with the lin

Re: [Tutor] Tkinter, widgets not displaying...

2006-02-10 Thread Hugo González Monteverde
Hi Kent and John, Thanks a lot for the advice on how to improve my program. I will look into separating the data and model as John suggests here. I didn't know about after_idle() and after(); seems that dir()'ing the classes sometimes gives out a lot more information than you can chew at any g

Re: [Tutor] nutshell review

2006-02-10 Thread Kent Johnson
nephish wrote: > yeah, one of the guys that posted earlier mentioned late feb as a > release of the new one. i think i am going to go ahead and get the > cookbook now, and then pick up the new nutshell later. It's the third edition of Python Essential Reference that is due Feb 24. Judging from hi

Re: [Tutor] nutshell review

2006-02-10 Thread carl.badgley
See I couldn't tell if he was talking about the Nutshell book or the Python Essential Reference book...thanksCarlOn 2/10/06, nephish < [EMAIL PROTECTED]> wrote:yeah, one of the guys that posted earlier mentioned late feb as a release of the new one. i think i am going to go ahead and get thecookboo

Re: [Tutor] nutshell review

2006-02-10 Thread nephish
yeah, one of the guys that posted earlier mentioned late feb as a release of the new one. i think i am going to go ahead and get the cookbook now, and then pick up the new nutshell later. sk On Fri, 2006-02-10 at 09:56 -0600, [EMAIL PROTECTED] wrote: > Isn't there supposed to be a new edition of t

Re: [Tutor] nutshell review

2006-02-10 Thread carl.badgley
Isn't there supposed to be a new edition of the Nutshell book coming out?  I was kinda hanging back for that one...Carl Badgley ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tkinter, widgets not displaying...

2006-02-10 Thread Kent Johnson
John Fouhy wrote: > If you want to do multithreaded programming with a GUI, one good way > is to use .after_idle. > > ie, instead of myturns.insert(str(i)), do > top.after_idle(myturns.insert, str(i)) (I think this is the right > syntax). This will cause the mainloop thread to run the code inste

Re: [Tutor] Tkinter, widgets not displaying...

2006-02-10 Thread Kent Johnson
Hugo González Monteverde wrote: > Hi All, > > I wrote a small turn delivering graphical app that is supposed to > display turns in a queue. > def insert(self, turn_string): > """Insert a new turn into the queue, move the rest upwards, > delete oldest.""" This is overly complicate

Re: [Tutor] quirky multiple inheritance example!?

2006-02-10 Thread Kent Johnson
Alan Gauld wrote: >> It's worse than that - with MI if you call __init__() explicitly and >> the base classes call super().__init__(), one of the base class >> __init__() methods will be called twice. See >> http://fuhm.net/super-harmful/ for an example. >> > > Excellent link Kent. This just hi

Re: [Tutor] quirky multiple inheritance example!?

2006-02-10 Thread Alan Gauld
> It's worse than that - with MI if you call __init__() explicitly and the > base classes call super().__init__(), one of the base class __init__() > methods will be called twice. See http://fuhm.net/super-harmful/ for an > example. > Excellent link Kent. This just highlights how woefully inade

Re: [Tutor] quirky multiple inheritance example!?

2006-02-10 Thread Kent Johnson
Alan Gauld wrote: > Having said that I still don't like that mechanism since it makes the > behaviour of the subclass depend on the implementation of the > superclass. That is, if I choose to create a sub class of someone elses > class then a call to super will only work if the other person has

[Tutor] pyGtk using combobox

2006-02-10 Thread thomas
Hi, I would like to make a combobox with a list of strings, but I have many problems with it. I know how to make the combobox and how to add strings, but is it possible to get a list of strings from the combobox and also is it possible to update the combobox with a list of strings? (something lik

Re: [Tutor] IDE - Editors - Python

2006-02-10 Thread [EMAIL PROTECTED]
What about It's an Editor based on wxPython. NewEdit uses Mixin and Plugin technique as its architecture. Most of its classes can be extended via mixin and plugin components, and finally become an integrity class at creating the instance. So NewEdit is very dynamic. You can write the new featur

Re: [Tutor] nutshell review

2006-02-10 Thread Alan Gauld
> That tracks my feelings. I don't find "Programming Python" to be very > useful. It's not the sort of reference book that, say, "Programming Perl" > > hasten to add, I've seen enough people swear how much they love that book, > that this may just be idiosyncratic to me.) One thing to note

Re: [Tutor] quirky multiple inheritance example!?

2006-02-10 Thread Alan Gauld
> Works for me. Each class must call super(...).__init__(). The first arg > >>> class A(object): > ... def __init__(self): > ... print 'A.__init__()' > ... super(A, self).__init__() > ... > >>> class B(object): > ... def __init__(self): > ... print 'B.__init__()' > ...