Re: On properties, use object instead?
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mark Hahn wrote: > "Mukhsein Johari" <[email protected]> wrote > >> I'm not sure if objects have set_, get_ methods but if >> they did, we would not need prop keyword to implement >> properties. >> >> Simply (using the example in the tutorial wiki): >> >>>> object Widget: >> ... price = 76 >> ... tax = 2.12 >> ... >> 2.12 >>>> w = Widget() >> <Object:c08db8> >>>> w.tax >> 2.12 >>>> with Widget: >> ... object tax: # change tax to a 'property' >> ... def get_(): # define get_ method >> ... return self.price * 0.03 > > Yes, that would work. I was just using "prop" for syntax sugar and > readability. > > Comments? votes? OOPS! Correction. It would have to be: with Widget: object tax(Property): # change tax to a 'property' def get_(): # define get_ method return self.price * 0.03 Otherwise it would have the problem that Lenard pointed out.