python typing hints code example
Example 1: python typing effect
from time import sleep
import sys
string = "The Battle Cats For Life" # Whatever string you want
for letter in string:
sleep(0.01) # In seconds
sys.stdout.write(letter)
sys.stdout.flush()
Example 2: python typing list of strings
from typing import List
def my_func(l: List[int]):
pass
Example 3: typing python
from collections.abc import Iterable
def zero_all_vars(vars: Iterable[LoggedVar[int]]) -> None:
for var in vars:
var.set(0)
Example 4: type declaration python
def greeting(name: str) -> str:
return 'Hello ' + name