what is wrong?
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Thu Feb 24 12:00:26 EST 2005
More information about the Python-list mailing list
Thu Feb 24 12:00:26 EST 2005
- Previous message (by thread): what is wrong?
- Next message (by thread): what is wrong?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 24 Feb 2005 08:34:09 -0800, rumours say that neutrinman at myrealbox.com might have written: >I cannot find out why the following code generates the error: >Traceback (most recent call last): > File "D:/a/Utilities/python/ptyhon22/test.py", line 97, in ? > main() > File "D:/a/Utilities/python/ptyhon22/test.py", line 60, in main > crit = Critter(crit_name) > File "D:/a/Utilities/python/ptyhon22/test.py", line 8, in __init__ > self.feed = feed # I wrote this >AttributeError: can't set attribute >I add some codes to a program on a book. The lines that have "I wrote >this" comment is the added codes. Could anyone tell me what is worng >here? [snip] >class Critter(object): This fails as you said: > self.feed = feed # I wrote this [snip] And this would fail: > def __feed_time(self): # I worte this > self.feed += 1 # I wote this Because of this: > feed = property(__get_feed) # I wrote this which specifies only a 'get' method for the property. [snip] feed is a property, and there is not 'set' method for it, so it's behaving as read-only. Search for 'property' in your python docs. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually...
- Previous message (by thread): what is wrong?
- Next message (by thread): what is wrong?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list