Re: [Tutor] print() invalid syntax (Jim Gallaher)

2014-12-24 Thread Jim Gallaher
> Message: 2 > Date: Tue, 23 Dec 2014 18:27:10 + > From: stuart kurutac > To: "tutor@python.org" > Subject: [Tutor] print() invalid syntax error > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > Hello all, > > I'm working my way through the Michael Dawson book "Python Pro

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

2014-12-24 Thread WolfRage
I wrote some code recently to make a linked list of Nodes for a 2d graph, so it consists of rows and columns. Now I wanted to make the code support being doubly linked, forwards and backwards. The difficult part of this is that the links are per row and per column. But the code I think is over

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

2014-12-24 Thread Steven D'Aprano
On Wed, Dec 24, 2014 at 04:35:06PM -0500, WolfRage wrote: > I wrote some code recently to make a linked list of Nodes for a 2d > graph, so it consists of rows and columns. Now I wanted to make the code > support being doubly linked, forwards and backwards. The difficult part > of this is that t

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

2014-12-24 Thread WolfRage
OK thanks for the rapid response, I will start rewriting the functions in this way now, and will come back with what I wind up with. Also Merry Christmas! On 12/24/2014 04:56 PM, Steven D'Aprano wrote: On Wed, Dec 24, 2014 at 04:35:06PM -0500, WolfRage wrote: I wrote some code recently to make

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

2014-12-24 Thread WolfRage
Here is a condensed version of all of the applicable code but with out Linked List filled in, as I am preparing to re-write it. class GameTile(): def __init__(self, id, **kwargs): self.id = id class GameGrid(): def __init__(self, **kwargs): self.cols = 8 self.row

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

2014-12-24 Thread Danny Yoo
Quick comment: the structure of the code here catches my eye: > # Each variable below is a link to the head Node in the respective > # row or column. > self.row0 = None > self.row1 = None > self.row2 = None > self.row3 = None > self.row4 = N

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

2014-12-24 Thread Danny Yoo
On Wed, Dec 24, 2014 at 1:35 PM, WolfRage wrote: > I wrote some code recently to make a linked list of Nodes for a 2d graph, so > it consists of rows and columns. Now I wanted to make the code support being > doubly linked, forwards and backwards. What are the _operations_ you want to support? C

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

2014-12-24 Thread Danny Yoo
> It seems highly regular; the code here is maintaining a collection of > row variables. Because it's so regular, you might consider using a > list to represent this collection. Concretely: > > self.rows = [None, None, None, None, None, None, None, None, None, None] Whoops. Apologies: I sh