Why would a language NOT use Short-circuit evaluation?

Reasons NOT to use short-circuit evaluation: Because it will behave differently and produce different results if your functions, property Gets or operator methods have side-effects. And this may conflict with: A) Language Standards, B) previous versions of your language, or C) the default assumptions of your languages typical users. These are the reasons that VB … Read more

Ansible: check if variable equals string

Be careful with a variable called environment, it can cause problems because Ansible uses it internally. I can’t remember if it’s in the docs, but here’s a mailing list thread: https://groups.google.com/forum/#!topic/ansible-project/fP0hX2Za4I0 We use a variable called stage. It looks like you’ll end up with a bunch of these in a row: – include_vars: testing_vars.yml when: … Read more

Assignment Condition in Python While Loop

Starting Python 3.8, and the introduction of assignment expressions (PEP 572) (:= operator), it’s now possible to capture an expression value (here sys.stdin.read(1)) as a variable in order to use it within the body of while: while (i := sys.stdin.read(1)) != ‘\n’: do_smthg(i) This: Assigns sys.stdin.read(1) to a variable i Compares i to \n If … Read more