473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Re: Quesion on class.attributes assignment



John Hanks wrote:
Hi,

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:
http://agolb.blogspot.com/2006/01/su...in-python.html
Here I am concerned is how attribute matrix.rows is changed. Through pdb
debugging, I can see in line 97, once "self.solutions = 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
self.solutions = set((val,))
self.matrix.changed = True
for other in self.row+self.col+self.submatrix:
if other is self: continue
if other.solutions == self.solutions: raise DeadEnd()
other.delSolutions(self.solutions)

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.

tjr

Jul 25 '08 #1
0 830

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kerry Neilson | last post by:
Hi, Really hung up on this one. I'm trying to get all the fields of a dictionary to be unique for each class: class A { my_dict = dict_entry = { 'key1':0, 'key2':0 } __init__(self): for...
8
by: Mark English | last post by:
I'd like to write a Tkinter app which, given a class, pops up a window(s) with fields for each "attribute" of that class. The user could enter values for the attributes and on closing the window...
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
27
by: guoliang | last post by:
help: #include<stdio.h> int main(void) { int a; char b; printf("int=");
5
by: Bob B. | last post by:
I've been playing with descriptors lately. I'm having one problem I can't seem to find the answer to. I want to assign a descriptor to a list of attributes. I know I should be able to add these...
13
by: globalrev | last post by:
wassup here? 7 Traceback (most recent call last): File "C:\Python25\myPrograms\netflix\netflix.py", line 22, in <module> print cust1.getID() AttributeError: 'NoneType' object has no...
13
by: John Dann | last post by:
A Python newbie, but some basic understanding of how classes, objects etc work in eg VB.Net. However, I'm struggling a little to translate this knowledge into the Python context. I'm trying to...
0
by: John Hanks | last post by:
Hi, 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:...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.