Re Iptscrae Python and While

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bluexcell

    Re Iptscrae Python and While

    While:
    This repeatedly tests the expression and, if it is true, executes the first
    suite; if the expression is false (which may be the first time it is tested)
    the suite of the else clause, if present, is executed and the loop terminates.

    The problem with using While as a scanner loop is the loop cycle is carried out
    at the natural cycle rate and is fixed, also one would have to define a
    function that contained a while loop in order to control it remotely,?

    What i want is a loop in which the the cycle rate is a variable, so it can be
    controlled globally from other functions, I also need to set a variable to
    start and stop the loop so i can call it and set it globally from other
    functions and i can see that is possible, by containing the While loop in a
    function.
    The purpose of the loop is to scan for events, these are the #body, and the
    result of those function calls may require a change in the scan rate or for the
    scan to stop and command to pass elswhere.. ie another function. While can be
    exited using break i know and it can resume using continue. but it seems an
    unwieldy and ugly way to do it.
    I will study it further though.. perhaps there is a clean way i havent seen
    yet.
    Thanks. Incony
  • Terry Reedy

    #2
    Re: Re Iptscrae Python and While


    "Bluexcell" <bluexcell@aol. com> wrote in message
    news:2004022518 0158.08854.0000 0402@mb-m13.aol.com...[color=blue]
    > What i want is a loop in which the the cycle rate is a variable, so it[/color]
    can be[color=blue]
    > controlled globally from other functions, I also need to set a variable[/color]
    to[color=blue]
    > start and stop the loop so i can call it and set it globally from other
    > functions and i can see that is possible, by containing the While loop[/color]
    in a[color=blue]
    > function.[/color]

    I do not quite understand what you want to do. However, when a while loop
    inside a function contains a yield statement, then cycling is controlled by
    calling .next on the resulting gen-iterator. This can be done from
    multiple places, by any function with a reference to the iterator. Hope
    this at least gives you more ideas.

    Terry J. Reedy




    Comment

    Working...