Problems with properties martin.witte at
Fri Oct 14 17:53:08 CEST 2005

If you change it to this it works. You should provide a get and a set
function for a property.

class Task:
   def __init__(self, value):
     self._command = value

   def setCommand(self, value):
     self._command = value

   def getCommand(self):
     return self._command

   command=property(getCommand, setCommand)

class taskTest(TestCase):
     def testTask(self):
         t = Task("dir c:")
         c = t.command
         self.assertEquals("dir c:", c)

         # should fail, but doesn't
         t.command = "foo Bar"
         self.assertEquals("dir c:", t.command)

if __name__ == "__main__": 

More information about the Python-list mailing list