Re: easy properties
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > it struck me that if you had set_(), get_() and del_() setup for > assignment in the root object, then you could streamline this example > and remove "prop", or am i missing something? > > > Proto1 = Object() > with Proto1: > x=6 > with x: > def get_(): > print "return ",super.x > return super.x > def set_(v): > super.x = v > print "set ",super.x,v > return v > def del_(): > print "attempt to delete (correct response)" When I originally proposed properties a long time ago in the mailing list this is exactly what I proposed. You can check the archives. I think it turned out to be too simple too implement. You can either check the archives for the old discussion or you can try to work out the details for yourself. I may be wrong but it didn't work for me when I went through the exercise before. BTW: super doesn't do what you want here. super works with prototype links, not attribute ownership. That is why my proto implementation makes "self" point to the attribute owner (Proto1). This way you can just say self.x to get to that level.