malanb5
malanb5

Reputation: 304

Specifying Types of Parameters and Return Values in Python

I want to specify types in the function definition such as:

def foo(grid : List[List[str]]) -> int:
    return 0

However when I run it in the interpreter (3.7.6), it states ModuleNotFoundError: No module named "List". Does anyone have documentation as to where I can read more about specifying the types of parameters and return values? How would I go about accomplishing this?

Upvotes: 0

Views: 35

Answers (1)

rdas
rdas

Reputation: 21275

It's from the typing module:

from typing import List


def foo(grid : List[List[str]]) -> int:
    return 0

See typing.List

Upvotes: 2

Related Questions