Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
boolean result of loop
#18
(Apr-02-2017, 11:34 PM)wavic Wrote: The second way, isn't it deprecated?
Deprecated usually means it was recommended at the time :)

It was an ok hack, but the behavior is not the same. When you build the list, its contents get evaluated, whereas with the longer form or the ternary expression it evaluates only what it needs to. This is important if there are side effects (aka EVIL) or even if there is a performance cost associated with one or both values.
Reply


Messages In This Thread
boolean result of loop - by Skaperen - Mar-31-2017, 01:47 AM
RE: boolean result of loop - by wavic - Mar-31-2017, 02:27 AM
RE: boolean result of loop - by Skaperen - Mar-31-2017, 05:50 AM
RE: boolean result of loop - by Ofnuts - Mar-31-2017, 08:30 AM
RE: boolean result of loop - by Skaperen - Apr-01-2017, 04:10 AM
RE: boolean result of loop - by buran - Apr-01-2017, 04:48 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 05:02 AM
RE: boolean result of loop - by buran - Apr-01-2017, 05:13 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 06:09 AM
RE: boolean result of loop - by ichabod801 - Apr-01-2017, 10:45 AM
RE: boolean result of loop - by wavic - Apr-01-2017, 11:20 AM
RE: boolean result of loop - by buran - Apr-01-2017, 12:07 PM
RE: boolean result of loop - by ichabod801 - Apr-01-2017, 12:42 PM
RE: boolean result of loop - by Skaperen - Apr-02-2017, 01:03 AM
RE: boolean result of loop - by Skaperen - Apr-02-2017, 02:52 AM
RE: boolean result of loop - by Ofnuts - Apr-02-2017, 08:33 PM
RE: boolean result of loop - by wavic - Apr-02-2017, 11:34 PM
RE: boolean result of loop - by micseydel - Apr-02-2017, 11:50 PM
RE: boolean result of loop - by wavic - Apr-02-2017, 11:56 PM
RE: boolean result of loop - by ichabod801 - Apr-03-2017, 12:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Running A Loop Until You See A Particular Result knight2000 6 32,139 Sep-04-2021, 08:55 AM
Last Post: knight2000
  Noob Alert! Wrong result using loop and if statemnent GJG 7 3,091 Dec-19-2020, 05:18 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020