Detecting a click on the turtle screen when the turtle isn't doing anything?

Adam Funk a24061 at
Wed Feb 6 22:46:17 CET 2013

On 2013-02-05, Dave Angel wrote:

> I'm no fan of Java.  But it's not about a "main" method, it's about 
> sharing data between functions.  Most of the time non-constant globals 
> are a mistake.  If the data can't be passed as an argument, then it 
> should probably be part of the instance data of some class.  Which class 
> is a design decision, and unlike Java, I wouldn't encourage writing a 
> class for unrelated functions, just to bundle them together.

Well, I understand the OO principle there, but it seems practical to
accept a few global variables in the "main" code of a program.

> Anyway, back to your problem.  Since your code doesn't have threads, it 
> must have an event loop somewhere.  Event loops don't coexist at all 
> well with calls to sleep().
>      while waiting:
>          time.sleep(1)
> If you start that code with waiting being true, it will never terminate.

Right.  But the following *does* work (although it's probably

def wait_for_click(s, t):
    global waiting
    waiting = True
    while waiting:

A lot of people never use their intiative because no-one
told them to.                                 --- Banksy

More information about the Python-list mailing list