On Sat, 12 Nov 2022 at 06:42, Stefan Ram <r...@zedat.fu-berlin.de> wrote: > > "Weatherby,Gerard" <gweathe...@uchc.edu> writes: > >I'd personally find it weird to see an all-cap parameter > > In the source code of the standard library, all-caps > notation is used for a parameter name sometimes > if that parameter name is "URL" or sometimes > when it is being initialized from an all-caps name as in: > > |def __del__(self, _warn=warnings.warn, RUN=RUN): > | if self._state == RUN: > ... > from "pool.py". > > ("RUN=RUN" makes RUN have the value "RUN" had > at the time of the definition of the function.) >
There are a few reasons to do that "snapshot" trick. The most common is performance, but in this case, my guess is that (since it's a __del__ method) it's to ensure that the objects are still referenced when this function is called - to stop them getting disposed of prematurely. Very rare, but important occasionally. ChrisA -- https://mail.python.org/mailman/listinfo/python-list