Created
October 11, 2015 01:04
-
-
Save konstantinos-tsatsarounos/30a33fbda849dd589785 to your computer and use it in GitHub Desktop.
Python simple interval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __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