[Python-ideas] A user story concerning things knowing their own names
Larry Hastings
larry at hastings.org
Wed Mar 16 16:10:21 CET 2011
On 03/16/2011 05:28 AM, Greg Ewing wrote:
> If I could write my overridable_property declarations
> without having to repeat the name, this kind of thing would
> not be able to happen.
As I suggested in my email on the Assignment Decorators thread this
morning, you could achieve this in current Python, no extension needed:
def assign(fn):
return fn(fn.__name__)
@assign
def content_size(name):
return overridable_property(name, "Size of the content area.")
How bad do you want it? ;-)
/larry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110316/6832d794/attachment.html>
More information about the Python-ideas
mailing list