On 24/10/2021 03:48, Steven D'Aprano wrote:
On Sun, Oct 24, 2021 at 01:16:02PM +1100, Chris Angelico wrote:


And is it really a problem if we delay the late-binding to the point
where the value is actually needed? Here's a toy example:

     # Using only early binding.
     def function(spam, eggs=None, cheese=None):
         if eggs is None:
             eggs = cheap_default()
         # do stuff using eggs
         ...
         if condition:
             return result
         if cheese is None:
             cheese = expensive_default()
         # do stuff using cheese
         ...
         return result


-1.  Too confusing.  Consider

    def function(a, ct=>len(a)):
        if random.randint(0,1):
            a.append(42)
        for i in range(ct):
            # presumably ct may or may not be 1 more than the original length of a

Best wishes
Rob Cliffe
_______________________________________________
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/JP6RRLHJ4FAMNYSW7CMLOEXT2GLBBLLE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to