Re: [Tutor] Confused about __setitem__

2008-12-04 Thread bob gailer
Jim Hodgen wrote: I am learning Python with a minesweeper-engine project. Future activities turn my attention to exploring the use of dictionaries as sparse matrices, hence the representation of the gameboard. Why can't I fill the dictionary-as-a-matrix with an instance of class Square? Wh

Re: [Tutor] Confused about __setitem__

2008-12-04 Thread Kent Johnson
On Thu, Dec 4, 2008 at 3:54 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > These are all class level variables so they will be shared if you > create more than one instance of the class. That's probably > not what you want?. You should initialise them inside an __init__ > method if you want each squa

Re: [Tutor] Confused about __setitem__

2008-12-04 Thread Alan Gauld
"Jim Hodgen" <[EMAIL PROTECTED]> wrote Why can't I fill the dictionary-as-a-matrix with an instance of class Square? You can but you are not trying to do that in your code. You are assigning Square to the class that contains the dictionary, not the dictionary itself. class Square: mined

[Tutor] Confused about __setitem__

2008-12-03 Thread Jim Hodgen
I am learning Python with a minesweeper-engine project. Future activities turn my attention to exploring the use of dictionaries as sparse matrices, hence the representation of the gameboard. Why can't I fill the dictionary-as-a-matrix with an instance of class Square? Why do I need a custo