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
2
  • 3
    Do you want sterileInput(options: list[str])? Commented May 30, 2022 at 12:29
  • 1
    What is shown here is not a type hint, but a default value for the parameter. Commented Mar 29, 2023 at 0:43

1 Answer 1

6

You can use the typing module

from typing import List
def sterileInput(options: List[str]) -> str:
    pass
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.