On 01/12/2015 05:00 PM, Alan Gauld wrote:
<SNIP>
Sorry, no time to read the detail, but one thing I thought might be
handy is to convert the draw method to return a string and make it the
__str__methodf of the grid.
Then the draw method becomes print(self)
And you can also just use print(aGrid) etc.
Something like (untested):
def __str__(self):
output = []
for row in self.transposed_grid:
s='| '
for node in row:
s += (str(node) + ' | ')
output.append(s)
return '\n'.join(output)
def draw(self): print (self)
Just a thought.
OK. I will implement this, thanks. It goes well with the __str__ method
of the tiles/nodes.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor