By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,362 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,362 IT Pros & Developers. It's quick & easy.

Re: Quesion on class.attributes assignment

P: n/a

John Hanks wrote:

I am reading a python program now but I just cannot understand how the
values of class attributes are assigned and changed. Here is the
original code url:
Here I am concerned is how attribute matrix.rows is changed. Through pdb
debugging, I can see in line 97, once " = set((val,))" is
executed, cell.row and matrix.rows will be updated. But I did not see
any assignment codes here. How could this change happen then? Thanks a lot!
Newsreaders do not typically have line counters. I presume you are
referring to
def setSolution(self, val):
self.solved = True = set((val,))
self.matrix.changed = True
for other in self.row+self.col+self.submatrix:
if other is self: continue
if == raise DeadEnd()

First, self is an instance of the class, so these are all instance
attributes, not class attributes. The difference is important.

As to your question, the last line mutates (modifies, updates) each
member of self.row, self.col, and self.submatrix that is not self
itself. The method delSolutions has the actual target rebindings.


Jul 25 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.