On Wed, Jun 23, 2010 at 10:13 PM, Steven D'Aprano wrote:
> On Thu, 24 Jun 2010 04:09:38 am Alan Gauld wrote:
>> "Steven D'Aprano" wrote
>>
>> > The easiest way is to just run forever, and stop when the user
>> > interrupts it with ctrl-D (or ctrl-Z on Windows):
>>
>> I think that would be Ctrl-C
On Thu, 24 Jun 2010 04:09:38 am Alan Gauld wrote:
> "Steven D'Aprano" wrote
>
> > The easiest way is to just run forever, and stop when the user
> > interrupts it with ctrl-D (or ctrl-Z on Windows):
>
> I think that would be Ctrl-C on both.
> Ctrl-D/Z is EOF not Interrupt. Certainly on Windows Ctr
My code has two bugs. If any command other than an int is entered, it falls
over ungracefully. Also, if any integers other than 1 or 0 are entered
successively it exits the Python interpreter.
I thought I would point this out so as not to mislead the OP.
On Wed, Jun 23, 2010 at 8:09 PM, Alan Gaul
"Steven D'Aprano" wrote
The easiest way is to just run forever, and stop when the user
interrupts it with ctrl-D (or ctrl-Z on Windows):
I think that would be Ctrl-C on both.
Ctrl-D/Z is EOF not Interrupt. Certainly on Windows Ctrl-Z won't
interrupt a loop.
But the principle is good and
Steven D'Aprano wrote:
On Wed, 23 Jun 2010 10:29:11 pm Nethirlon . wrote:
Hello everyone,
I'm new at programming with python and have a question about how I
can solve my problem the correct way. Please forgive my grammar,
English is not my primary language.
I'm looking for a way to repeat
^^ I meant time.sleep(x), rather. Please excuse the double post.
On Wed, Jun 23, 2010 at 4:29 PM, Sithembewena Lloyd Dube
wrote:
> My two cents' worth added below. Seems to do what you want. You probably
> want to call sys.wait(x) after printing an error, so it can be read before
> exiting?
>
> i
My two cents' worth added below. Seems to do what you want. You probably
want to call sys.wait(x) after printing an error, so it can be read before
exiting?
import os, sys, time
def check(host):
try:
output = os.popen('ping -ns 1 %s' % host).read()
alive = output.find('Reply fro
On 6/23/2010 6:51 AM Steven D'Aprano said...
# untested
def call_again(n, func, *args):
"""call func(*args) every n seconds until ctrl-D"""
import time
try:
while 1:
start = time.time()
func(*args)
time.sleep(n - (time.time()-start))
On Wed, 23 Jun 2010 10:29:11 pm Nethirlon . wrote:
> Hello everyone,
>
> I'm new at programming with python and have a question about how I
> can solve my problem the correct way. Please forgive my grammar,
> English is not my primary language.
>
> I'm looking for a way to repeat my function every
On 23 June 2010 13:29, Nethirlon . wrote:
> Hello everyone,
>
> I'm new at programming with python and have a question about how I can
> solve my problem the correct way. Please forgive my grammar, English
> is not my primary language.
>
> I'm looking for a way to repeat my function every 30 seco
Hello everyone,
I'm new at programming with python and have a question about how I can
solve my problem the correct way. Please forgive my grammar, English
is not my primary language.
I'm looking for a way to repeat my function every 30 seconds.
As an example I have written a ping function. But
11 matches
Mail list logo