Chris Angelico wrote:
> On Fri, Jul 29, 2011 at 7:03 AM, Ethan Furman <[email protected]> wrote:
>> I'll use a lambda to get around it, but that's not very elegant. Why
>> shouldn't NoneType be able to return the singleton None?
>
> Why a lambda?
>
> def ThisFunctionWillReturnNone():
> pass
This is a good use-case for a lambda. Ethan's use-case is a dict of
constructors:
fielddef = { 'empty':some_func, 'null':some_func }
There's no need to expose the constructor outside of the dict, hence:
fielddef = { 'empty': str, 'null': lambda: None }
does the job. No need for a top-level named function.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list