Overwrite only one function with property()

K

Kai Kuehne

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
 
G

George Sakkis

Kai said:
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
 
G

gagsl-py

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?
 
B

Bruno Desthuilliers

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top