[Python-ideas] Fwd: Null coalescing operator
Chris Angelico
rosuav at gmail.com
Tue Sep 13 10:24:35 EDT 2016
On Wed, Sep 14, 2016 at 12:14 AM, Random832 <random832 at fastmail.com> wrote:
> On Tue, Sep 13, 2016, at 07:37, Nick Coghlan wrote:
>> P.S. There are also some use cases where Look-Before-You-Leap is
>> inherently subject to race conditions,
>
> Which use cases *aren't*?
Ones in which no external force can affect things. For example:
def frob(spam):
if spam is None:
print("Frobbing nothing")
else:
print("Frobbing some spam: ", spam)
...
You can safely assume that locals won't be changed between the 'is
None' check and the print. I suppose someone could mess around with
thread call stacks, but that'd be seriously insane.
ChrisA
More information about the Python-ideas
mailing list