[Python-ideas] A user story concerning things knowing their own names

Michael Foord fuzzyman at gmail.com
Thu Mar 17 02:15:35 CET 2011

On 16 March 2011 19:18, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> Larry Hastings wrote:
>     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?  ;-)
> Not quite badly enough to replace all my existing
> overridable_property declarations with something that
> ugly. :-) But I appreciate the suggestion, and I'll
> keep it in mind next time I'm designing anything
> similar.

You should be able to replace it with something like:

   def content_size():
       return "Size of the content area."

Where do_something calls the function to get the string argument and takes
the name from the function.__name__ (and uses them to create and return the


> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110316/cc513921/attachment.html>

More information about the Python-ideas mailing list