[Tutor] Get/Set/Attribute Accessors in Python?

Malcolm Newsome malcolm.newsome at gmail.com
Fri Dec 7 14:19:45 CET 2012


On 06/12/2012 11:54, Steven D'Aprano wrote:
> On 06/12/12 15:42, Mark Lawrence wrote:
>> On 05/12/2012 16:58, Steven D'Aprano wrote:
>>>
>>> And here is how it should be written in Python:
>>>
>>> class Example(object):
>>> def __init__(self, value):
>>> self.x = value
>>>
>>> instance = Example(42)
>>> print instance.x # gives 42
>>> instance.setx(23)
>>>
>>
>> And introduce error handling while we're at it? Should we consider a
>> CutAndPasteError in Python? :)
>
> Oh the shame! I am disgraced!
>
> /me hangs head in shame
>
> Thanks for catching the error.
>

>I can't say I'll lose too much sleep over it. IIRC 30 years ago an
>emergency release was done, all signed off by the appropriate >people,
>and the integration team couldn't load the software onto the system.
>Why?  It handn't compiled, someone had taken out one line too many >with
>the editor!!!  Now we're giving advice in relatively real time, and
>sometimes we get it wrong.  Thankfully not so costly to the UK >taxpayer.
>
>--
>Cheers.
>
>Mark Lawrence.


It's akin to Michael Jordan missing a three-pointer at the buzzer to lose a
game...it can happen to the best of us.  :-)

Best,
Malcolm Newsome
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121207/49a76e3f/attachment.html>


More information about the Tutor mailing list