0

This looks like a short circuit way of writing code but I just can't understand it. Is there a specific way to read this kind of short circuit.

e.g: n = n and int(n) n = n or int(n)

user1113186
  • 65
  • 1
  • 2
  • 8

1 Answers1

0

and conditions return the last truthy value or the first falsy one. So if n is falsy, n will remain whatever value it was. If n is truthy, it will be cast to an int.

mVChr
  • 49,587
  • 11
  • 107
  • 104
  • this makes sense. so n = n or int(n) would mean that whatever n would evaluate to ( if n is true or false), next expression int(n) won't be evaluated (it would be skipped)? – user1113186 Jan 05 '17 at 17:12