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

2015-01-02 Thread WolfRage
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 row, we have some rules that only certain combinations will

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

2015-01-02 Thread WolfRage
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 row, we have some rules that only certain combinations will result in an elimination. In general 2 of the same value in a row with with 1 of 2 other possible

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
First, thanks Joseph for taking the time to reply. My comments interspersed below: On Fri, Jan 2, 2015 at 2:39 PM, Joseph Lee joseph.lee22...@gmail.com wrote: Hi, Answers are below. -Original Message- From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On

Re: [Tutor] threading in python2.7

2015-01-02 Thread Alan Gauld
On 02/01/15 20:17, Rance Hall wrote: I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Snap!(ish), I got an arduino Uno and RaspberryPi. As I understand it the pcDuino is just a PC and

Re: [Tutor] threading in python2.7

2015-01-02 Thread Joseph Lee
Hi, Answers are below. -Original Message- From: Tutor [mailto:tutor-bounces+joseph.lee22590=gmail@python.org] On Behalf Of Rance Hall Sent: Friday, January 2, 2015 12:17 PM To: tutor Subject: [Tutor] threading in python2.7 Each of the lights and sound functions are placed in a while

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 09:57:29AM -0800, Alex Kleider wrote: On 2015-01-01 17:35, Alan Gauld wrote: Repeats replicates the reference to the object but does not create a new object. This part I can understand but, as Steven has pointed out, this behaviour changes if the object being

[Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Working with development boards has me navigating the inner working of python threading and I find myself at a loss. My current project

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 11:37:12AM -0500, WolfRage wrote: On 01/02/2015 02:21 AM, Steven D'Aprano wrote: Your lookup_node method returns a GameTile or False on failure: def lookup_node(self, x, y, ): if not self.check_bounds(x, y): return False return

Re: [Tutor] thread-breaing

2015-01-02 Thread Dave Angel
On 01/02/2015 05:35 PM, WolfRage wrote: 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 You forgot to start a new thread. A new thread isn't changing the subject in the middle of a deeply nested thread. A

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Ben Finney
Brandon Dorsey brandon...@gmail.com writes: I know there is are easier ways to assign multiple objects to a variable, Not really. Every name binds to exactly one value. Values can themselves be collections of other values, which might be what you're thinking of. Why does it return a tuple

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Dave Angel
On 01/02/2015 05:25 AM, Brandon Dorsey wrote: I know there is are easier ways to assign multiple objects to a variable, but why, does the following code work? Why does it return a tuple versus a list? I know it has something to do with the semi-colon, but I didn't know it wouldn't raise an

[Tutor] multiple objects with one assignment?

2015-01-02 Thread Brandon Dorsey
I know there is are easier ways to assign multiple objects to a variable, but why, does the following code work? Why does it return a tuple versus a list? I know it has something to do with the semi-colon, but I didn't know it wouldn't raise an error. greetings = hello,, what's, your, name?

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 06:51:16AM -0500, Brandon Dorsey wrote: On Fri, Jan 2, 2015 at 6:34 AM, Steven D'Aprano st...@pearwood.info wrote: The thing to remember is that *commas*, not parentheses, are used for making tuples. The round brackets are just for grouping. That's what I was

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
On 01/02/2015 12:28 AM, Dave Angel wrote: On 01/01/2015 11:48 PM, WolfRage wrote: Final Code Using 2d List instead of Doubly Linked List. Please don't top-post. Instead, post your comments inline with the parts of the previous message to which you're responding. I did reply in-line, but

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. I normally use mutt, but for this post I've used Thunderbird. It is an old

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Alan Gauld
On 02/01/15 14:49, WolfRage wrote: class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id Still showing double spaced and without indent to me, on Thunderbird... I use Thunderbird for posting too, and nobody has complained yet about my code layout. My account

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 05:25:12AM -0500, Brandon Dorsey wrote: I know there is are easier ways to assign multiple objects to a variable, but why, does the following code work? Why does it return a tuple versus a list? I know it has something to do with the semi-colon, but I didn't know it

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
import sys class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id class GameGrid(): def __init__(self, **kwargs): self.cols = 8 self.rows = 8 # grid is 2d array as y, x ie [y][x]. self.grid = [[None] * self.rows for i in range(self.cols)] def

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Brandon Dorsey
On Fri, Jan 2, 2015 at 6:34 AM, Steven D'Aprano st...@pearwood.info wrote: The thing to remember is that *commas*, not parentheses, are used for making tuples. The round brackets are just for grouping. That's what I was confused about. I didn't realize commas defined tuples, not parentheses.

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
On 01/02/2015 10:37 AM, Alan Gauld wrote: I use Thunderbird for posting too, and nobody has complained yet about my code layout. My account settings are: CompositionAddressing Compose in HTML - OFF Auto quote original then START REPLY BELOW QUOTE My Tbird prefs are: Composition-General tab-

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
On 01/02/2015 02:21 AM, Steven D'Aprano wrote: What is the purpose of the **kwargs? It doesn't get used, it just silently ignores them. Hopefully you got the answer for this from the previous message. Why does the GameTile record the coordinates as strings? Hopefully you got the answer for

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 10:53 AM, WolfRage wrote: On 01/02/2015 10:37 AM, Alan Gauld wrote: I use Thunderbird for posting too, and nobody has complained yet about my code layout. My account settings are: CompositionAddressing Compose in HTML - OFF Auto quote original then START REPLY BELOW QUOTE My

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On Sat, Jan 03, 2015 at 02:40:39AM +1100, Steven D'Aprano wrote: On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. Another

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 10:55 AM, Dave Angel wrote: On 01/02/2015 10:43 AM, Steven D'Aprano wrote: On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. Another test. This time I have re-enabled HTML posting for my account, but set

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Steven D'Aprano
On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. One last test. I've removed python.org from the Plain text only domains, so

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Brandon Dorsey
On Fri, Jan 2, 2015 at 6:08 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Does it help you to understand if I clarify that a tuple is one value? That a list is one value? That a dict is one value? Well I knew that those data structures represent one value that can hold x amount of objects,

Re: [Tutor] multiple objects with one assignment?

2015-01-02 Thread Brandon Dorsey
On Fri, Jan 2, 2015 at 6:27 AM, Dave Angel da...@davea.name wrote: Ben's description is very good. But I think the main thing you're missing is that a tuple is created by the comma, not by parentheses. In some contexts, parentheses need to be added to make it non-ambiguous, since comma is

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

2015-01-02 Thread Dave Angel
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 straight 3 in a row, we have some rules

Re: [Tutor] threading in python2.7

2015-01-02 Thread Rance Hall
On Fri, Jan 2, 2015 at 3:18 PM, Alan Gauld alan.ga...@btinternet.com wrote: On 02/01/15 20:17, Rance Hall wrote: I bought myself a pcduino 3 nano development board for Christmas and started picking up python again after a long forced hiatus. The board runs Ubuntu Precise Snap!(ish), I

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Alex Kleider
On 2015-01-02 13:57, Steven D'Aprano wrote: On Fri, Jan 02, 2015 at 09:57:29AM -0800, Alex Kleider wrote: On 2015-01-01 17:35, Alan Gauld wrote: Repeats replicates the reference to the object but does not create a new object. This part I can understand but, as Steven has pointed out, this

Re: [Tutor] Fwd: Newbie

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 11:51:04PM +0530, Rohan Ds wrote: Hello everybody :) I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I want to contribute to PSF. The information available on the site didn't really answer my questions. What sort of

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

2015-01-02 Thread Alan Gauld
On 03/01/15 02:00, WolfRage wrote: Dave sorry for not posting a new thread correctly, I did not realize the list was so smart. Take a look at the mail headers (More actions-View source in TBird) Specifically the References header. It links each message to all those above it in the thread. If

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

2015-01-02 Thread Dave Angel
On 01/02/2015 09:38 PM, Alan Gauld wrote: On 03/01/15 02:00, WolfRage wrote: What is breaing? I think he meant breaking I'm afraid some keys currently stick, and 'k' is one of them. Every so often I lose a key. -- DaveA ___ Tutor

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
On 01/02/2015 02:21 AM, Steven D'Aprano wrote: Fixing the mangled formatting, as best as I am able (and can be bothered). On Thu, Jan 01, 2015 at 11:48:18PM -0500, WolfRage wrote: class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id What is

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
On 01/02/2015 12:08 PM, Dave Angel wrote: class GameGrid(): def __init__(self, cols=8, rows=7, **kwargs): You probably want to reverse the order of the parameters; you've got almost everything else row-major You are right, a lot of inconsistency that will lead to errors latter on. I

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 11:37 AM, WolfRage wrote: On 01/02/2015 02:21 AM, Steven D'Aprano wrote: What is the purpose of the **kwargs? It doesn't get used, it just silently ignores them. Hopefully you got the answer for this from the previous message. Why does the GameTile record the coordinates as

Re: [Tutor] Fwd: Newbie

2015-01-02 Thread Alan Gauld
On 02/01/15 18:21, Rohan Ds wrote: Hello everybody :) Hi, welcome. I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I want to contribute to PSF. The information available on the site didn't really answer my questions. It will help if you tell

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 12:57 PM, Alex Kleider wrote: On 2015-01-01 17:35, Alan Gauld wrote: Repeats replicates the reference to the object but does not create a new object. This part I can understand but, as Steven has pointed out, this behaviour changes if the object being repeated is immutable. Why

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Alex Kleider
On 2015-01-01 17:35, Alan Gauld wrote: Repeats replicates the reference to the object but does not create a new object. This part I can understand but, as Steven has pointed out, this behaviour changes if the object being repeated is immutable. Why would one get a new object (rather than a

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 10:43 AM, Steven D'Aprano wrote: On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. One last test. I've removed

[Tutor] Fwd: Newbie

2015-01-02 Thread Rohan Ds
-- Forwarded message -- From: Rohan Ds rohan0...@gmail.com Date: 2 Jan 2015 23:46 Subject: Newbie To: tut...@python.org Cc: Hello everybody :) I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I want to contribute to PSF. The

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Alan Gauld
On 02/01/15 19:03, WolfRage wrote: Tutors, on my next iteration I am going to add more of the game code. Since I am no longer using Doubly Linked Lists, should I create a new thread? Or should I continue with this thread to continue with the established context? Since you are now just looking

Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread WolfRage
Tutors, on my next iteration I am going to add more of the game code. Since I am no longer using Doubly Linked Lists, should I create a new thread? Or should I continue with this thread to continue with the established context? ___ Tutor maillist -