Using type hints on an array function input
Question:
I recently read this post which talks about using an array as a function input, and was just wondering if it was possible to use type hints to hint that the array is meant to be an array of str
?
for example:
def sterileInput(options = []) -> str:
# ^ I want to hint that this array contains strings
pass
Answers:
You can use the typing
module
from typing import List
def sterileInput(options: List[str]) -> str:
pass
I recently read this post which talks about using an array as a function input, and was just wondering if it was possible to use type hints to hint that the array is meant to be an array of str
?
for example:
def sterileInput(options = []) -> str:
# ^ I want to hint that this array contains strings
pass
You can use the typing
module
from typing import List
def sterileInput(options: List[str]) -> str:
pass