
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. A question: As I understand it, the function is never actually bound to its name, i.e. in your first example the name "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. 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 :x = weakref.ref(obj, lambda) def (obj): print("{} is being destroyed".format(obj)) or even (reusing lambda again) :x = weakref.ref(obj, lambda) lambda (obj): print("{} is being destroyed".format(obj)) On Thu, Oct 13, 2011 at 6:45 AM, Carl M. Johnson < cmjohnson.mailinglist@gmail.com> wrote:
I really like the proposal, although I would be interested to see if anyone can bikeshed up keywords that might be better than : or @… :-)
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?--
:sorted_list = sorted(original, key=normalize) def normalize(item): …
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.
-- Carl Johnson _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas