Overwrite only one function with property()

Discussion in 'Python' started by Kai Kuehne, Nov 18, 2006.

  1. Kai Kuehne

    Kai Kuehne Guest

    Hi list!
    It is possible to overwrite only one function with the property-function?

    x = property(getx, setx, delx, 'doc')

    I just want to overwrite setx, but when I set the others to None,
    I can't read and del the member. Any ideas or is this not possible?

    Thank you!
    Kai
     
    Kai Kuehne, Nov 18, 2006
    #1
    1. Advertising

  2. Kai Kuehne wrote:

    > Hi list!
    > It is possible to overwrite only one function with the property-function?
    >
    > x = property(getx, setx, delx, 'doc')
    >
    > I just want to overwrite setx, but when I set the others to None,
    > I can't read and del the member. Any ideas or is this not possible?


    There are no default functions for getx, setx, delx; you have to
    specify what you expect to happen when you write a.p, a.p = v and del
    a.p, respectively. What would, for example, be the default getx that
    you don't want to overwrite ?

    George
     
    George Sakkis, Nov 18, 2006
    #2
    1. Advertising

  3. Kai Kuehne

    Guest

    On 18 nov, 19:06, "Kai Kuehne" <> wrote:

    > It is possible to overwrite only one function with the property-function?
    >
    > x = property(getx, setx, delx, 'doc')
    >
    > I just want to overwrite setx, but when I set the others to None,
    > I can't read and del the member. Any ideas or is this not possible?


    Do you want to override the setter of an existing property, in a
    derived class?
     
    , Nov 18, 2006
    #3
  4. Kai Kuehne a écrit :
    > Hi list!
    > It is possible to overwrite only one function with the property-function?


    property is not function, it's a class. And it doesn't "overwrite" anything.

    > x = property(getx, setx, delx, 'doc')
    >
    > I just want to overwrite setx, but when I set the others to None,
    > I can't read and del the member.


    You don't "overwrite" setx, you pass it as an argument to the property
    constructor call.

    > Any ideas or is this not possible?


    Read this, and you'll have a detailed answer:
    http://users.rcn.com/python/download/Descriptor.htm


    > Thank you!
    > Kai
     
    Bruno Desthuilliers, Nov 19, 2006
    #4
    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. chris
    Replies:
    2
    Views:
    329
    Nicodemus
    Mar 1, 2004
  2. Matt@revera
    Replies:
    4
    Views:
    323
    Erik Max Francis
    Apr 7, 2005
  3. Andy
    Replies:
    5
    Views:
    583
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
  4. Vikas Gholap
    Replies:
    1
    Views:
    112
  5. Chris
    Replies:
    1
    Views:
    95
    Mick White
    Aug 4, 2004
Loading...

Share This Page