Skip to content

Instantly share code, notes, and snippets.

@konstantinos-tsatsarounos
Created October 11, 2015 01:04
Show Gist options
  • Select an option

  • Save konstantinos-tsatsarounos/30a33fbda849dd589785 to your computer and use it in GitHub Desktop.

Select an option

Save konstantinos-tsatsarounos/30a33fbda849dd589785 to your computer and use it in GitHub Desktop.
Python simple interval
__author__ = 'Konstantinos Tsatsarounos'
import time;
greeting = "hello";
# a simple print func
def console(str):
print(str);
def timer(callback,x):
# call callback if is indeed a function
if( callable(callback)):
callback(greeting);
# wait for 300ms
time.sleep(0.3);
# the x defines the number of repeats
# the sleep time the duration between iterations
if(x > 1):
timer(callback,x-1);
return x;
# initialize the timer func
timer(console, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment