Re: [Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread grouchy
Hi John,Thanks for that suggestion.I tried replacing my matrix with a numpy array, and it was about 20% slower, but I just substituted one for the other, so that really isn't surprising.  I didn't try with the built-in array, but I'm guessing that swapping out another container for lists would only

Re: [Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread John Fouhy
On 19/09/05, grouchy <[EMAIL PROTECTED]> wrote: > I've been playing with generating 1-D cellular automata, and this is the > fastest solution I've come up with so far. I haven't dug deep into your code --- but, I wonder if the array module might help? -- John. __

[Tutor] Any suggestions for optimizing this code?

2005-09-18 Thread grouchy
Hello again!I've been playing with generating 1-D cellular automata, and this is the fastest solution I've come up with so far. In the makeArray() function below, I have a sliding window of three elements starting at row[-1,0,1] and going to row[-2,-1,0], so that it wraps around at either boundary.

Re: [Tutor] pychart and debian

2005-09-18 Thread nephish
Danny Yoo wrote: >>ok, got the package installed, but it seems to not be working, or the >>examples are messed up. >>here is the source >> >>from pychart import * >>theme.get_options() >>data = [["Jan", 10], ["Feb", 22], ["Mar", 30]] >> >>ar = area.T(x_coord = category_coord.T(data, 0), >>

Re: [Tutor] tuples and mysqldb tables

2005-09-18 Thread Danny Yoo
> def run(self): > try: > ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > ss.connect((ip, port_counter)) > print "%s | %d OPEN" % (ip, port_counter) > ss.close() > except: pass Hi Ed, Yikes. Don't do that. *grin* By "that",

Re: [Tutor] pychart and debian

2005-09-18 Thread Danny Yoo
> ok, got the package installed, but it seems to not be working, or the > examples are messed up. > here is the source > > from pychart import * > theme.get_options() > data = [["Jan", 10], ["Feb", 22], ["Mar", 30]] > > ar = area.T(x_coord = category_coord.T(data, 0), > y_range = (0, No

Re: [Tutor] tuples and mysqldb tables

2005-09-18 Thread Ed Hotchkiss
  I was cheap and I skimmed through "programming python" then jumped off a cliff and went right into it with a ripped parachute. I did a tutorial today and I solved the problem. I'm having a problem with threads and sockets now ... I wrote a lot of code for this and it should work based on my under

Re: [Tutor] pychart and debian

2005-09-18 Thread nephish
Danny Yoo wrote: >On Sun, 18 Sep 2005, nephish wrote: > > > >>anyone have luck getting pychart installed on debian ? there is no >>debian package for it (that i have found thus far) and i need something >>that will allow me to place some simple x, y plots on a chart in pygtk. >> >> > >Hi sk,

Re: [Tutor] Best Encryption for Python Client/Server

2005-09-18 Thread Danny Yoo
On Sun, 18 Sep 2005, Ed Hotchkiss wrote: > Let us say that I am trying to create a very small and simple private > network/connection between several scripts on different machines, to > communicate instructions/data/files etc. to each other over the net. Is > SSL the best method? Any recommendat

Re: [Tutor] tuples and mysqldb tables

2005-09-18 Thread Danny Yoo
Hi Ed, Let's look at one of your questions: > How do I use a loops to iterate through the nested tuple Let's separate this apart from the SQL stuff for the moment. Are you familiar with Python's for loop, and how it can work on sequences? For example: ## >>> authors = ['fowler', 'lau',

Re: [Tutor] pychart and debian

2005-09-18 Thread Danny Yoo
On Sun, 18 Sep 2005, nephish wrote: > anyone have luck getting pychart installed on debian ? there is no > debian package for it (that i have found thus far) and i need something > that will allow me to place some simple x, y plots on a chart in pygtk. Hi sk, Ah, found it. It's in the 'testin

Re: [Tutor] How do you organize code snippets?

2005-09-18 Thread Danny Yoo
On Sun, 18 Sep 2005, List wrote: > The subject pretty much says it. I tend to clip and save snippets from > various lists for later reference. I save each in a separate text file > more or less named appropriately (or so I think at the time), but I've > ended up with a mess of files in a snippet

[Tutor] tuples and mysqldb tables

2005-09-18 Thread Ed Hotchkiss
I have used fetchall() to insert the values from a table into a tuple. anywhere from 0 - ? many rows could be in this tuple, so it is a row within a row. How do I use a loops to iterate through the nested tuple, and assign the tuples integers and strings to variables, ugh :P   The Tables data is l

[Tutor] Best Encryption for Python Client/Server

2005-09-18 Thread Ed Hotchkiss
Let us say that I am trying to create a very small and simple private network/connection between several scripts on different machines, to communicate instructions/data/files etc. to each other over the net. Is SSL the best method? Any recommendations of something to get started with? Thanks in adv

Re: [Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread bob
At 10:30 AM 9/18/2005, Kent Johnson wrote: >Marcin Komorowski wrote: > > I know that one of the ways to iterate over sorted dictionary keys is: > > keylist = dictionary.keys() > > keylist.sort() > > for key in keylist: > > ... > > > > Is there a way to do this in a single line.

Re: [Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread John Fouhy
On 19/09/05, Marcin Komorowski <[EMAIL PROTECTED]> wrote: > Is there a way to do this in a single line. Something like this would be > ideal: > for key in dictionary.keys().soft(): Hi Marcin, Others have already answered you, but just to follow up: There is a reason why lst.sort() returns

[Tutor] pychart and debian

2005-09-18 Thread nephish
Hey there, anyone have luck getting pychart installed on debian ? there is no debian package for it (that i have found thus far) and i need something that will allow me to place some simple x, y plots on a chart in pygtk. if any of you have a better solution, i am not completely sold out to pychar

Re: [Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread Kent Johnson
Marcin Komorowski wrote: > I know that one of the ways to iterate over sorted dictionary keys is: > keylist = dictionary.keys() > keylist.sort() > for key in keylist: > ... > > Is there a way to do this in a single line. Something like this would > be ideal: > for key in

Re: [Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread Pawel Kraszewski
Dnia niedziela, 18 września 2005 19:20, Marcin Komorowski napisał: > I know that one of the ways to iterate over sorted dictionary keys is: > keylist = dictionary.keys() > keylist.sort() > for key in keylist: > ... Indeed, 'sort' sorts its argument in-place and returns 'none'.

Re: [Tutor] How do you organize code snippets?

2005-09-18 Thread Poor Yorick
List wrote: > Is there a way of naming or organizing snippets that might help? (For > example, file i/o snippets, text processing snippets, etc.) > If you really want to have fun, you can use LEO, http://webpages.charter.net/edreamleo/front.html to store your code snippets and generate files

[Tutor] Iterating over sorted dictionary keys in one line

2005-09-18 Thread Marcin Komorowski
I know that one of the ways to iterate over sorted dictionary keys is:     keylist = dictionary.keys()     keylist.sort()     for key in keylist:         ...   Is there a way to do this in a single line.  Something like this would be ideal:     for key in dictionary.keys().soft():        

[Tutor] Fwd: Re: How do you organize code snippets?

2005-09-18 Thread Don Arnold
Note: forwarded message attached. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com--- Begin Message --- --- List <[EMAIL PROTECTED]> wrote: > The subject pretty much says it. I tend to clip and > save snippets from var

[Tutor] IRC Client Trouble -- too many new lines

2005-09-18 Thread Joseph Quigley
Hi, My IRC Client can't print the IRC server messages without a newline for each message in a giant list that I recieve... here's my code: import socket, string, sys #some user data, change as per your taste class Data: SERVER = 'irc.freenode.net' CHANNEL = "#python" NICKNAME = "Pyth

[Tutor] How do you organize code snippets?

2005-09-18 Thread List
The subject pretty much says it. I tend to clip and save snippets from various lists for later reference. I save each in a separate text file more or less named appropriately (or so I think at the time), but I've ended up with a mess of files in a snippets directory and I can't always remember what