3 ms·
The "weakref.ref()" advice is helpful but I would add that "weakref.proxy()" is often what you want instead of "weakref.ref()" because it does not require the r
by makecheck 8y ago
The "weakref.ref()" advice is helpful but I would add that "weakref.proxy()" is often what you want instead of "weakref.ref()" because it does not require the real object type to be known.
Also, I wish Python would make exceptions and "with" easier to combine. It feels like there is always this unwelcome extra level of indentation when code may raise exceptions, and I would rather have a "try with" or something to remove that. This keeps me from using context managers for relatively simple steps that might otherwise be convenient, since it looks better to just do the simple steps as part of a try/except/finally that has to be there anyway.