[Python-ideas] Allowing def to assign to anything

Alexander Walters tritium-list at sdamon.com
Mon Oct 26 02:19:43 EDT 2015


This too leaves artifacts in the module, which is one of the annoyances 
I am trying to eliminate.  Though I do admit that it makes the intent of 
the author clear.  It still feels less pythonic to me than allowing a 
statement that assigns to just assign to anything assignable.

On 10/26/2015 02:15, Bruce Leban wrote:
> Decorators easily support this:
>
> dispatch_table = {}
> def dispatch(arg):
>     def inner(func):
> dispatch_table[arg] = func
>         return func
>     return inner
>
> @dispatch('foo')
> def dispatch_foo(bar):
>     pass

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151026/8750e73a/attachment-0001.html>


More information about the Python-ideas mailing list