473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: Enhanced property decorator

Daniel <mi*******@gmail.comwrites:
I've often been frustrated by the inability of the built-in property
descriptor to handle anything other than a read-only property when
used as a decorator.
The fact that the 'property' function works as a decorator (in, as you
point out, some cases only) is a happy accident. The 'property'
function isn't *designed* to be used as a decorator, it just happens
to work that way.
Solution 1: new built-in function/descriptor
[…]
Solution 2: Enhance the built-in property descriptor
[…]
Solution 3: […] require new syntax for the yield keyword, which
would yield an unnamed function object (similar to a lambda object).
[…]

All of these require changes in Python or its standard library.

Here are some solutions that work now, with Python as it is, for using
decorators to implement full-featured properties
<URL:http://wiki.python.org/moin/PythonDecoratorLibrary#head-d6f79f980db88e0bdf258e9c9e7d34ce37b43eee>.

--
\ “Try to learn something about everything and everything about |
`\ something.” —T.H. Huxley |
_o__) |
Ben Finney
Aug 26 '08 #1
0 905

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Ron_Adam | last post by:
I was having some difficulty figuring out just what was going on with decorators. So after a considerable amount of experimenting I was able to take one apart in a way. It required me to take a...
4
by: Colin J. Williams | last post by:
Is there some way that the user can access the docstring specified for a property? Please see the example below: # propDocTest class A(object): def __init__(self, value): self.value= value...
8
by: lab3terch | last post by:
I have built an enhanced button control which I want to use to capture the number of times the button has been clicked. I have added the new control to a test program but cannot get it to work. The...
0
by: lab3terch | last post by:
I have built an enhanced button control which I want to use to capture the number of times the button has been clicked. I have added the new control to a test program but cannot get it to work. The...
0
by: lab3terch | last post by:
I am using Visual Studio.NET 2003 and have built a enhanced button control (enhbutton) to capture the number of times the button has been clicked. I did the code and did a build. I then added a test...
11
by: king kikapu | last post by:
Hi to all, i am trying to use properties in Python and i am sure i have made something wrong with the below code but i just cannot see what it is. Can anyone please help me on this ? The...
4
by: thomas.karolski | last post by:
Hi, I would like to create a Decorator metaclass, which automatically turns a class which inherits from the "Decorator" type into a decorator. A decorator in this case, is simply a class which...
0
by: Gabriel Genellina | last post by:
En Mon, 25 Aug 2008 22:45:36 -0300, Daniel <millerdev@gmail.comescribi: (Some days late, sorry...) I like the variant below, based on your code. It avoids issue (2) by using locals(). Works...
14
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.