Writing a read only attribute

Discussion in 'Python' started by Fabrizio Pollastri, Jul 6, 2007.

  1. Hello,
    it is possible to force in some way a write to a read-only attribute of
    a python object? In which case?
    Thanks for any answer.

    F. Pollastri
     
    Fabrizio Pollastri, Jul 6, 2007
    #1
    1. Advertising

  2. On Jul 6, 8:27 am, Fabrizio Pollastri <> wrote:
    > Hello,
    > it is possible to force in some way a write to a read-only attribute of
    > a python object? In which case?
    > Thanks for any answer.
    >
    > F. Pollastri


    What do you mean by read-only attribute?
    If you are trying to change attributes of built-in objects, there is
    no hope:

    >>> 'astring'.upper = 2

    ---------------------------------------------------------------------------
    exceptions.AttributeError

    AttributeError: 'str' object attribute 'upper' is read-only

    If the read-only attribute has been implemented via a property, there
    is a way
    to write it, but you should tell us more about your case.

    Michele Simionato
     
    Michele Simionato, Jul 6, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ferro
    Replies:
    2
    Views:
    373
    Adam Maass
    Nov 1, 2003
  2. Brian Genisio

    Read Only Attribute?

    Brian Genisio, Jan 8, 2004, in forum: C++
    Replies:
    7
    Views:
    425
    Howard
    Jan 14, 2004
  3. keithb
    Replies:
    2
    Views:
    8,078
    keithb
    Jun 7, 2006
  4. Replies:
    3
    Views:
    1,611
    Brandon McCombs
    May 2, 2007
  5. Fabrizio Pollastri

    Writing a read only attribute

    Fabrizio Pollastri, Jul 6, 2007, in forum: Python
    Replies:
    2
    Views:
    270
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Jul 6, 2007
Loading...

Share This Page