pythonpython-3.xfunction-definition

Python3 function definition, arrow and colon


I have found the following python function definition:

def reverseString(self, s: 'List[str]') -> 'None':

I don't quite understand 'List[str]' and -> 'None'.

I have found that the arrow is a function annotation but I couldn't find anything useful and understandable for List[str].

Is it just an annotation? or does it enforce that the type of parameter s must be a string array?


Solution

  • It's just python type hinting, You can learn more in PEP 484