Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #112264

Re: make an object read only

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: make an object read only
Date Wed, 03 Aug 2016 09:57:42 +0200
Lines 16
Message-ID <mailman.132.1470211075.6033.python-list@python.org> (permalink)
References <c6a0318e-af2c-4390-ab4c-a6e0fa35891a@googlegroups.com> <87mvku9te1.fsf@handshake.de>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace news.uni-berlin.de iRR0UsjHvGvjA/ThspRjhw13phIf8+LCRVNOnfcSnTLg==
Cancel-Lock sha1:MLJ0uIzn7eu9XAxxrUF0alYjnI0=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'reject': 0.05; 'used.': 0.05; 'canvas': 0.07; 'assigning': 0.09; 'immutable': 0.09; "object's": 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'attributes,': 0.16; 'called,': 0.16; 'dictionaries': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'repeatedly,': 0.16; 'subject:make': 0.16; 'subject:object': 0.16; '(by': 0.22; 'mixed': 0.22; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'skip:" 20': 0.26; 'methods.': 0.29; 'objects': 0.29; 'implement': 0.32; 'says': 0.32; 'changing': 0.34; 'lists': 0.34; 'could': 0.35; 'instance': 0.35; 'quite': 0.35; 'level': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'there,': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'things': 0.38; 'doing': 0.38; 'wrong': 0.38; 'to:addr:python.org': 0.40; 'save': 0.60; 'your': 0.60; 'our': 0.64; 'results': 0.66; 'becker': 0.84; 'elementary': 0.84; 'subject:read': 0.84
X-Injected-Via-Gmane http://gmane.org/
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <87mvku9te1.fsf@handshake.de>
X-Mailman-Original-References <c6a0318e-af2c-4390-ab4c-a6e0fa35891a@googlegroups.com>
Xref csiph.com comp.lang.python:112264

Show key headers only | View raw


Robin Becker <robin@reportlab.com> writes:

> A reportlab user found he was doing the wrong thing by calling canvas.save 
> repeatedly, our documentation says you should not use Canvas objects after the 
> save method has been used. The user had mixed results :(
>
> It would be better to make the canvas object completely immutable all the way 
> down when save has been called, but I think that's quite hard as these objects 
> have quite a large and varied set of attributes, lists other objects 
> dictionaries etc etc.

If changing things happen at an elementary level (by assigning to
the object's instance attributes), then you could implement
your on "__setattr__/__delattr__" methods. There, you could check
whether you are ready to allow the change or reject it.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

make an object read only Robin Becker <robin@reportlab.com> - 2016-08-02 08:12 -0700
  Re: make an object read only "dfh@forestfield.co.uk" <dfh@forestfield.co.uk> - 2016-08-02 09:28 -0700
  Re: make an object read only Steven D'Aprano <steve+python@pearwood.info> - 2016-08-03 02:36 +1000
  Re: make an object read only dieter <dieter@handshake.de> - 2016-08-03 09:57 +0200
  Re: make an object read only Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-04 17:03 -0700
    Re: make an object read only Robin Becker <robin@reportlab.com> - 2016-08-05 09:51 +0100
    Re: make an object read only Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-08-05 11:04 +0200
    Re: make an object read only Rick Johnson <rantingrickjohnson@gmail.com> - 2016-08-07 16:40 -0700

csiph-web