list as an instance attribute

Daniel Luis dos Santos daniel.dlds at gmail.com
Sat Sep 12 22:48:18 EDT 2009


Hello,

I have an object definition :

class primitive:

	def __init__(self)
		self.name = ""
		self.transforms = []

	def copy(self, copyName)

		copy = self.copyInternalState(copyName)  # method defined elsewhere 
in derived class

		if self.transforms != []
			for transf in self.transforms
				copy.transforms.append(transf.copy())


In short, what I want to is to have the transforms list as an instance 
attribute of the class. I will add objects to it. When I call the copy 
method on the object the list is to be copied to the new object.

Problem is that the python interpreter is complaining that it doesn't 
know any self.transforms in the if statement.

Help




More information about the Python-list mailing list