How about using lambda instead of @?  lambda on its own currently raises a syntax error, so this might be easier to implement that @.  Also, lambda is rather more descriptive than @ since it is already used in the context of unnamed functions.<div>

<br></div><div>A question: As I understand it, the function is never actually bound to its name, i.e. in your first example the name "<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">report_destruction" doesn't exist after the statement. If this is the case, then there seems little point assigning a name at all other than for providing a description. In fact, assigning a name implies that it is reusable and that the name means something.</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">I'm not sure I like the idea of allowing defs without a name, but perhaps its something to think about. So your first example could read</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">   :x = weakref.ref(obj, lambda)<br>

   def (obj):<br>       print("{} is being destroyed".format(obj))</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><br>

</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">or even (reusing lambda again)</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><br>

</span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255); "><div style="font-family: arial; font-size: small; "><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">   :x = weakref.ref(obj, lambda)<br>

   lambda (obj):<br>       print("{} is being destroyed".format(obj))</span></div><div><font class="Apple-style-span" face="arial, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><br>

</font></div></span></div><div><div class="gmail_quote">On Thu, Oct 13, 2011 at 6:45 AM, Carl M. Johnson <span dir="ltr"><<a href="mailto:cmjohnson.mailinglist@gmail.com">cmjohnson.mailinglist@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I really like the proposal, although I would be interested to see if anyone can bikeshed up keywords that might be better than : or @… :-)<br>


<br>
I do have some questions about it. Does using @ instead of the name defined below make the implementation easier? In other words, would this cause a NameError on normalize because normalize isn't defined in the local namespace?--<br>


<br>
:sorted_list = sorted(original, key=normalize)<br>
def normalize(item):<br>
   …<br>
<br>
Or is the @ just for brevity? I assume the point is that it's not just brevity, but you have to use the @ in order to make the implementation straightforward.<br>
<font color="#888888"><br>
-- Carl Johnson<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br></div>