-1

consider this:

valid = data and func(data)

In the cases where data will be False, will python still run the function on the right side of the and condition? (it will error if run, so I'm trying to figure out if I need to check data within func or is the above code fine as is)

yuvi
  • 18,155
  • 8
  • 56
  • 93
  • 4
    No. This is called short-circuiting. – cs95 Jul 07 '17 at 01:50
  • @cᴏʟᴅsᴘᴇᴇᴅ thank you. I was not familiar with the name `short-circuit` so I couldn't have found the duplicate question on my own – yuvi Jul 07 '17 at 01:55

1 Answers1

-1

Well, it's easy to try:

>>> 0 and False
0

so the answer is: python will not run func(data) if data is False.

Fabien
  • 4,862
  • 2
  • 19
  • 33