get/set
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon May 13 04:58:22 EDT 2002
[posted and mailed]
Alex Martelli <aleax at aleax.it> wrote in
news:J_5D8.46933$zW3.574094 at news1.tin.it:
>> Field descriptors are new with Python 2.2
>
> Yes.
>
>> and require the new-style
>> classes.
>
> No.
>
>>>> class X:
> ... def getTer(self): return 23
> ... def setTer(self, value): pass
> ... ter = property(getTer, setTer)
> ...
>>>> x = X()
>>>> x.ter
> 23
Unfortunately:
>>> x.ter = 5
>>> x.ter
5
The getTer works, but the setTer is ignored unless you have a newstyle
class.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list