[Tutor] Re: pausing time and perform on exit

Emile van Sebille emile@fenx.com
Thu Oct 31 20:36:01 2002


Kyle Babich:
> I actually have two questions--first do date I have never figured out
how to
> pause time.  The best of come up with is simple while loops that look
for
> something to happen but its fair to say I'm clueless.
>
> timetosleep = 0
> while timetosleep < 60:
>     time.sleep(1)

easier to do time.sleep(60)  ;-)  From the docstring:

>>> print time.sleep.__doc__
sleep(seconds)

Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.
>>>


> Also how would I tell the program to do something when the program is
exited
> by having the window closed to the computer shut down (anything with
the
> user manually typing 'quit' into the program)?  I don't even know
where to
> begin with this.
>

Marc Andre Lemburg speaks to this here:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=34DA199
E.FBC1C07%40uni-duesseldorf.de

The doc string from the post says:
    Singleton that manages exit functions. These function will be
    called upon system exit in reverse order of their registering.

So it sounds like you could (once could have?) queued up a number of
clean-up tasks to be performed before exitting.

HTH,

--

Emile van Sebille
emile@fenx.com

---------