It's documented in stdtypes.rst, so I think it's part of the standard library.
I think it's unnecessarily obfuscated though. On Mon, Mar 28, 2022 at 8:44 AM Robin Becker <ro...@reportlab.com> wrote: > A gentoo developer reported a symlink loop problem in reportlab's setup.py > where we search for specific headers. > > The 'fixed' function looks like this > > def findFile(root, wanted, followlinks=True): > visited = set() > for p, D, F in os.walk(root,followlinks=followlinks): > #scan directories to check for prior visits > #use dev/inode to make unique key > SD = [].append > for d in D: > dk = os.stat(pjoin(p,d)) > dk = dk.st_dev, dk.st_ino > if dk not in visited: > visited.add(dk) > SD(d) > D[:] = SD.__self__ #set the dirs to be scanned > for fn in F: > if fn==wanted: > return abspath(pjoin(p,fn)) > > the fix is reported to have worked, but the developer is querying the > lifting of SD.append using the construct > > SD = [].append > loop involving > appends to the list > ..... > D[:] = SD.__self__ > > his objection was that using __self__ might be implementation sensitive. > > I cannot tell from the documentation (eg > https://docs.python.org/3.10/reference/datamodel.html) if these magic > methods > are part of python or of the implementation. > > On the other hand as a longtime python programmer I wonder if such simple > cases are already optimized out in the > produced bytecode; for years I have been avoiding s += 'string' and only > recently found out that it was handled as a > special case. > -- > Robin Becker > _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/3TAF3LR35HRRE6LD7XQ7O4BXPNLVXFVX/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/6IMBFHOGAYJDDGJVPVYJNQJS4MICGJ7Q/ Code of Conduct: http://python.org/psf/codeofconduct/