Methods that mutate their argument typically return None, to avoid confusing them with methods that return copies;
If you both mutate and return a copy it is easy to end up with shared objects in place you actually don't want them >>> even = [2,4,6] >>> odd = [1,3,5] >>> all = odd.extend(even) ... oops. -- M On Wed, 3 Mar 2021 at 12:43, Hans Ginzel <h...@matfyz.cz> wrote: > > Please, is there a reason why extend() method does not return self? > > >>> a = [1,2].extend((3,4)) > >>> a > >>> type(a) > <class 'NoneType'> > >>> b = [1,2] > >>> b.extend((3,4)) > >>> b > [1, 2, 3, 4] > _______________________________________________ > 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/5BAHV7VURBOSFUCTPFPQ646CGMHB7RTP/ > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ 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/KGMZ6IUWTNN4SX27U2UHZAZSULAKNTBX/ Code of Conduct: http://python.org/psf/codeofconduct/