On Sun, May 24, 2020 at 01:38:26PM -0400, David Mertz wrote:

> The pattern:
> 
> def fun(..., option=None):
>     if option is None:
>         option = something_else
> 
> Becomes second nature very quickly.  Once you learn it, you know it.  A
> line of two of code isn't a big deal.

Sure, but when you have seven parameters that all take late-bound 
defaults, it becomes a PITA.

    def func(...):
        # late binding boilerplate
        if dopey is None:
        if happy is None:
        if doc is None:
        if sneezy is None:
        if grumpy is None:
        if sleepy is None:
        if bashful is None:
        # AAAAND at last we get to the actual function body...

This "if arg is None..." idiom is okay, but it's just a tiny bit of 
extra friction when coding. Nothing as drastic as a "design flaw" 
or a "wart" on the language, but it's slightly rough edge.

> But this discussion DOES remind me of something much more general that I've
> wanted for a long time, and that has had long discussion threads at various
> times.  A general `deferred` or `delayed` (or other spellign) construct for
> language-wide delayed computation would be cool. It would also require
> rethinking a whole lot of corners.  I think it would address this mutable
> default, but it would also do a thousand other useful things.

Well, I don't know about a thousand, but I'm currently writing up a 
proto-PEP for delayed evaluation, and I've got six use-cases so far.


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7MGWV5YFDYXRJBPOE5PCYL5FO5Q7MS6F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to