On 5/28/23 7:32 PM, Samuel Muldoon wrote:
*Currently, list.extend does not allow method chaining.*
*
*
*parameters = [
    "zero or more",
    "zero or more".upper(),
    "zero or more".lower(),
    "Zero or More"
*
*].extend(["(0, +inf)", "[0; +in**f]"])*
*
*
*parameters.extend(["{0, \u221E}"]).append("(0 inf)")
*
*
*

*Samuel Muldoon*

My understanding is that it is a deliberate choice that mutating member functions return NONE, rather than the object (to allow chaining) because otherwise it is too easy to think it return a new copy of the object (like operation that aren't mutations).

Thinking you got a new copy when you are working with the original object gives hard to find problems.

Since the operations return NONE, mistakenly trying to chain hits an obvious, and normally easy to fix error.

It just says that "chaining" has become less pythonic.

--
Richard Damon

_______________________________________________
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/YNH65BFGOLMC3BLRB4NCN6ADSXAWWDZ2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to