Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Do Operators use Lazy evaluation?

    General Code/Help
    2
    2
    276
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • greg nwosu
      greg nwosu last edited by

      does the AND operator evaluate its second operand if the first one evaluates to false?

      similarly for OR and IF are the operators lazy?

      1 Reply Last reply Reply Quote 0
      • Robin Dhillon
        Robin Dhillon last edited by

        AND refers to both the condition holding true/false and or refers to one of the conditions holding true/false.
        for example:

        val1 = 5.0
        val2 = 6.0
        if val1 > 2.0 and val2 < 10.0:
            print(True)
        

        this would fail if val2 was infact greater than 10.0
        for the 'OR' case:

        val1 = 5.0
        val2 = 6.0
        if val1 > 2.0 or val2 == 10.0:
            print('only condition one is true')
        
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors