0

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
Darcy Power
  • 195
  • 12

1 Answers1

5

You can use the typing module

from typing import List
def sterileInput(options: List[str]) -> str:
    pass
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Mystic Mickey
  • 100
  • 2
  • 6