Files
30-seconds-of-code/snippets/delay.md
Isabelle Viktoria Maciohsek 0ab4b3dbc5 Update snippet descriptions
2020-11-02 19:27:53 +02:00

387 B

title, tags
title tags
delay function,intermediate

Invokes the provided function after ms milliseconds.

  • Use time.sleep() to delay the execution of fn by ms / 1000 seconds.
from time import sleep

def delay(fn, ms, *args):
  sleep(ms / 1000)
  return fn(*args)
delay(lambda x: print(x), 1000, 'later') # prints 'later' after one second