Thanks for your comments. On Thu, Apr 23, 2009 at 11:52, Gary Herron <gher...@islandtraining.com> wrote: > > [...] > > There's no need for a specific addition to the syntax to do this. > > Try this: > > def foo_bar(): > return(...) > foo.bar = foo_bar > >> [...] > > and this: > > def foo_bar(): > return(...) > foo["bar"] = foo_bar >
I understand that this is possible now, but I just don't see why it's necessary to do it at all. >> In this case I could see there being a problem in that there's nothing >> to get the function's __name__ from, but that doesn't apply for the >> first example. >> > > Not sure what you mean here. >>> def foo(): pass ... >>> bar = foo >>> bar.__name__ 'foo' >>> If I defined foo.bar it would know that the method name was "bar", but if I defined foo["bar"] there's be no clear identifier to use for the function's name. I don't see this as a great problem, since anonymous functions already exist, but I thought it was worth acknowledging. To be clear, I don't see this as a serious fault in the language, but as an unnecessary restriction that makes code a little less direct than it could be. -- http://mail.python.org/mailman/listinfo/python-list