Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/03/2015 06:10 PM, WolfRage wrote: On 01/03/2015 04:42 PM, Dave Angel wrote: self.transposed_grid = list( zip(*self.grid) ) This results in the same thing with or with out the list() wrapper. Using Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux In Python 3, zip() retu

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 06:46 PM, Steven D'Aprano wrote: On Sat, Jan 03, 2015 at 06:10:31PM -0500, WolfRage wrote: On 01/03/2015 04:42 PM, Dave Angel wrote: self.transposed_grid = list( zip(*self.grid) ) This results in the same thing with or with out the list() wrapper. Using Python 3.4.0 (default, A

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Alan Gauld
On 03/01/15 23:10, WolfRage wrote: On 01/03/2015 04:42 PM, Dave Angel wrote: self.transposed_grid = list( zip(*self.grid) ) This results in the same thing with or with out the list() wrapper. Are you sure? Try inserting print(self.transposed_grid) immediately after the assignment and see i

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Steven D'Aprano
On Sat, Jan 03, 2015 at 06:10:31PM -0500, WolfRage wrote: > On 01/03/2015 04:42 PM, Dave Angel wrote: > >self.transposed_grid = list( zip(*self.grid) ) > This results in the same thing with or with out the list() wrapper. Using > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] on linux

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 04:42 PM, Dave Angel wrote: self.transposed_grid = list( zip(*self.grid) ) This results in the same thing with or with out the list() wrapper. Using Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux ___ Tutor maillist -

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 04:42 PM, Dave Angel wrote: On 01/03/2015 04:22 PM, WolfRage wrote: On 01/03/2015 06:58 AM, Dave Angel wrote: To transpose a grid, you want to use the zip() function. self.transposed_grid = zip(*self.grid) I see this gives me a list that is the column. Thus it solves the col

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/03/2015 04:22 PM, WolfRage wrote: On 01/03/2015 06:58 AM, Dave Angel wrote: To transpose a grid, you want to use the zip() function. self.transposed_grid = zip(*self.grid) I see this gives me a list that is the column. Thus it solves the column iteration problem, because now I can fe

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 06:58 AM, Dave Angel wrote: To transpose a grid, you want to use the zip() function. self.transposed_grid = zip(*self.grid) I see this gives me a list that is the column. Thus it solves the column iteration problem, because now I can feed it to my checking and elimination fun

Re: [Tutor] Seismometer alarm Python

2015-01-03 Thread Alan Gauld
On 03/01/15 19:19, Ted wrote: Alan Thank you so much for the reply, attached is a screenshot of a 4.9M earthquake in Challis Idaho, about 150 miles north. this is what I need the alarm for. I am using Python 2.7? and Windows 7. 1. Should I reply-all, or ok to you? or either? ReplyAll plea

Re: [Tutor] Fwd: Tutor Digest, Vol 131, Issue 14

2015-01-03 Thread Alan Gauld
On 03/01/15 18:07, Alan Gauld wrote: Forwarded to list for info. Please use ReplyAll in responses to the tutor list. Apologies, you did. It was stuck in the moderation queue. I've now taken you off moderation. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://w

Re: [Tutor] Seismometer alarm Python

2015-01-03 Thread Alan Gauld
On 03/01/15 17:06, Ted wrote: Hi Folks, I have a small python code to write. It has at least three parts, 1,2 and 3. I think I have 1 and 3 working. I do not know how this Tutor@python.org works, You post questions, the rest of us try to answer them. Please supply Python version, OS and th

[Tutor] Seismometer alarm Python

2015-01-03 Thread Ted
Hi Folks, I have a small python code to write. It has at least three parts, 1,2 and 3. I think I have 1 and 3 working. I do not know how this Tutor@python.org works, but if someone can email me I can explain my questions. I do not wish to get into too much detail, on this first email. Basica

Re: [Tutor] Tutor Digest, Vol 131, Issue 14

2015-01-03 Thread pramod gowda
Hello , I have chaged the code as per your input, except port number. If i change the port number it give me error as Traceback (most recent call last): File "C:\Users\Pramod\Desktop\client.py", line 7, in client_socket.connect((server_address,server_port)) ConnectionRefusedError: [WinErr

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Alan Gauld
On 03/01/15 16:14, WolfRage wrote: def check_total_and_eliminate(self, first, second, third): Steven said: I think this method does too much. I would prefer to see it split into two methods, one to check the total, and the other to eliminate the cells if needed: Yes, another example

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 06:58 AM, Dave Angel wrote: self.transposed_grid = zip(*self.grid) zip() sounds confusing. But I am going to try this and see what it gives me. But Somehow I think it will require me to understand yield, which I still do not totally get how to use. Also from the documentation, wil

Re: [Tutor] Fwd: Tutor Digest, Vol 131, Issue 14

2015-01-03 Thread Alan Gauld
Forwarded to list for info. Please use ReplyAll in responses to the tutor list. And please do not quote the entire digest, delete any irrelevant parts. On 03/01/15 16:00, pramod gowda wrote: Hello , I have chaged the code as per your input, except port number. If i change the port number it gi

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 10:09 AM, Steven D'Aprano wrote: On Fri, Jan 02, 2015 at 09:00:22PM -0500, WolfRage wrote: Python3.4+ Linux Mint 17.1 but the code will be cross platform (Mobile, Windows, Linux, OSX). First an explanation of how the game works: The game is a simple matching game but with a twist.

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/03/2015 06:58 AM, Dave Angel wrote: My error. Since nodes are GameTile objects, not values, converting to a tuple is a little trickier: values = tuple( [node.value for node in nodes] ) if values in table: do-something I will try an implement this after I s

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread WolfRage
On 01/02/2015 10:21 PM, Dave Angel wrote: This code is way too complex for what it accomplishes. See below. Yes, that it why it needs to be optimized. It is unfortunate that my first goes at many tasks are not the most efficient. But hopefully that will get better as I learn from all of you.

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 09:00:22PM -0500, WolfRage wrote: > Python3.4+ Linux Mint 17.1 but the code will be cross platform (Mobile, > Windows, Linux, OSX). > > First an explanation of how the game works: The game is a simple > matching game but with a twist. Instead of matching a straight 3 in a

Re: [Tutor] Socket programming

2015-01-03 Thread Alan Gauld
On 03/01/15 11:48, pramod gowda wrote: client code: import socket client_socket=socket.socket() server_address='192.168.2.2' server_port= 80 see below regarding port numbers print("hello") client_socket.connect((server_address,server_port)) print("hello") data=client_socket.recv(1024) prin

[Tutor] Socket programming

2015-01-03 Thread pramod gowda
Hi, i am learning socket programming, client code: import socket client_socket=socket.socket() server_address='192.168.2.2' server_port= 80 print("hello") client_socket.connect((server_address,server_port)) print("hello") data=client_socket.recv(1024) print(data) client_socket.close() server

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/02/2015 10:21 PM, Dave Angel wrote: On 01/02/2015 09:00 PM, WolfRage wrote: Python3.4+ Linux Mint 17.1 but the code will be cross platform (Mobile, Windows, Linux, OSX). First an explanation of how the game works: The game is a simple matching game but with a twist. Instead of matching a

Re: [Tutor] threading in python2.7

2015-01-03 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 12:39:36PM -0800, Joseph Lee wrote: > Threads introduce interesting issues. For instance, due to Python's global > interpreter lock (GIL), only one thread can run at a given time. I'd like to make a technical correction here. The GIL is not a *language* requirement, it is